ExchangePS Error: The WinRM Shell Client Cannot Process the Request
Related Queries
- "ExchangePS shell handle is not valid."
- "New-ExoPSSession fails with WinRM Shell client error."
- "ExchangeOnlineManagement 2.0.5 error with StealthAUDIT job."
- "Stealthbits Exchange data collector fails to connect."
Symptom
Jobs that use the ExchangePS data collector fail with the following error:
PowerShell error: System.Exception: New-ExoPSSession : Processing data from remote server outlook.office365.com failed with the following error message: The WinRM Shell client cannot process the request. The shell handle passed to the WSMan Shell function is not valid. The shell handle is valid only when WSManCreateShell function completes successfully.
Cause
This issue occurs when one or both of the following PowerShell modules are outdated or incompatible:
PackageManagementmodule version is earlier than1.0.0.1ExchangeOnlineManagementmodule version is2.0.5or earlier
These versions are known to cause instability with remote sessions using New-ExoPSSession.
Resolution
Step 1: Verify Installed Module Versions
Open a PowerShell session and run:
Get-Module -ListAvailable PackageManagement
Get-Module -ListAvailable ExchangeOnlineManagement
Step 2: Update Modules Using PowerShell (Preferred Method)
-
Update
PackageManagementmodule:Install-Module PackageManagement -Force -Scope AllUsers -
Update
ExchangeOnlineManagementmodule:Install-Module ExchangeOnlineManagement -Force -Scope AllUsers
IMPORTANT: Close and reopen all PowerShell sessions after updating modules.
Step 3: Manual Update (If Unable to Install via PowerShell)
If the environment prevents direct downloads from PowerShell, update the modules manually.
Download the .nupkg Files
-
Visit the following URLs:
-
Download the
.nupkgfile for each required version.
Convert .nupkg to ZIP and Extract
- Rename the downloaded
.nupkgfile to.zipExample:PackageManagement.1.4.8.1.zip - Unblock the ZIP file using one of the following methods:
- In File Explorer, right-click Properties > Unblock.
- Or run:
Unblock-File .\PackageManagement.1.4.8.1.zip
- Extract the contents of each ZIP file.
Rename the Extracted Folder
- Rename
PackageManagement.1.4.8.1to1.4.8.1 - Rename
ExchangeOnlineManagement.3.4.0to3.4.0(or the version you downloaded)
Move to PowerShell Modules Directory
Place the renamed folders in the correct directories:
- For PackageManagement:
C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.4.8.1 - For ExchangeOnlineManagement:
C:\Program Files\WindowsPowerShell\Modules\ExchangeOnlineManagement\3.4.0
Step 4: Confirm Module Versions
Re-run the version checks:
Get-Module -ListAvailable PackageManagement
Get-Module -ListAvailable ExchangeOnlineManagement
Ensure that:
PackageManagementis version 1.4.8.1 or newerExchangeOnlineManagementis version 2.0.6 or newer
IMPORTANT: Rerun jobs that use the ExchangePS data collector to confirm that the error message no longer appears.