How to fix "The WinRM client cannot process the request because the CustomRemoteShell URI specified is invalid."
Error Description
This error occurs when the Windows Remote Management (WinRM) client attempts to establish a connection using a custom connection URI or shell plugin that is missing, misconfigured, or not registered on the target remote computer. WinRM relies on specific Uniform Resource Identifiers (URIs) to route commands to the correct shell environment (like PowerShell or CMD). If the client specifies a CustomRemoteShell URI that the remote server does not recognize or support, the connection fails immediately.
Step-by-Step Fixes
Method 1: Reset the Shell Configurations to Default
The quickest fix is to restore the default WinRM shell configurations on both the local and remote machines.
- Open the Start Menu.
- Type cmd, right-click Command Prompt, and select Run as administrator.
- Type the following command to reset the WinRM configuration and press Enter:
winrm quickconfig - Type Y and press Enter if prompted to make changes.
- Next, restore the default shell namespaces by running:
winrm reset
Method 2: Use the Standard Connection URI in Your Script
If you are receiving this error while running a PowerShell session (New-PSSession or Invoke-Command), you may be explicitly passing an incorrect URI.
- Locate the script or command you are executing.
- Check for the
-ConnectionURIparameter. - Ensure you are using the standard PowerShell URI format instead of a custom one:
http://<RemoteComputerName>:5985/wsman - Alternatively, remove the
-ConnectionURIparameter entirely and use the plain-ComputerNameparameter instead:New-PSSession -ComputerName "TargetPC" -Credential (Get-Credential)
Method 3: Enable and Configure Remote Shell Access
Ensure that remote shell access is not restricted by Windows Group Policy or local configurations.
- Open Command Prompt as administrator.
- Run this command to check if remote shells are enabled:
winrm get winrm/config/winrs - If
AllowRemoteShellAccessis set to false, enable it by running:winrm set winrm/config/winrs @{AllowRemoteShellAccess="true"}
Method 4: Restart the WinRM Service
Sometimes the WinRM service fails to register its endpoints properly until the service is recycled.
- Press Windows Key + R to open the Run dialog box.
- Type services.msc and press Enter.
- Scroll down to find the Windows Remote Management (WS-Management) service.
- Right-click on it and select Restart.
There may be some errors. Learn Microsoft