Why This Happens
- Custom URI Misconfigurations: The endpoint or connection URI (Uniform Resource Identifier) passed to the command has a syntax error or an unsupported scheme.
- Corrupted WinRM Configurations: The local or remote WinRM listener configuration has become corrupted or misaligned.
- WS-Management Protocol Mismatches: The client is trying to use a remote shell type or custom plug-in configuration that is not registered or enabled on the target server.
- Corrupted System Files: Underlying Windows management files or dependencies are damaged.
Step-by-Step Fixes
Follow these solutions in order. Test your connection after completing each step to see if the issue is resolved.
Step 1: Run the WinRM Quick Configuration
This utility resets the default WinRM settings, enables the listener, and creates the required firewall exceptions.
- Click the Start menu, type
cmd, right-click Command Prompt, and select Run as administrator. - Type the following command and press Enter:
winrm quickconfig - If prompted to make changes and enable the service, type
yand press Enter. - Type the following command to check if the listener is running properly:
winrm e winrm/config/listener
Step 2: Verify and Reset the Connection URI
If you are running a specific PowerShell script or command (like Enter-PSSession or New-PSSession), the custom URI parameter may be incorrect.
- Ensure you are not manually passing an invalid
-ConnectionURIparameter. A standard WinRM URI looks like this:http://<ComputerName>:5985/wsman - If you are using a custom shell, verify that the URI string strictly adheres to the schema required by your target application.
- Try connecting using the standard
-ComputerNameparameter instead of the custom URI parameter to see if the default shell works:Enter-PSSession -ComputerName Target Computer Name
Step 3: Add the Target Host to the TrustedHosts List
The client machine will reject connections to untrusted endpoints unless they are explicitly added to the local configuration.
- Open PowerShell as an Administrator.
- Run this command to view your current trusted hosts:
Get-Item WSMan:\localhost\Client\TrustedHosts - To trust a specific computer, run:
Set-Item WSMan:\localhost\Client\TrustedHosts -Value "Target Computer Name" -Force(Note: You can use `` as the value to trust all computers, though this is only recommended for isolated testing environments).*
- Restart the WinRM service to apply the changes:
Restart-Service WinRM
Step 4: Repair Corrupted WinRM Plug-ins and Shells
If a custom remote shell registration is corrupted, resetting the shell infrastructure can resolve the issue.
- Open Command Prompt as an Administrator.
- Run this command to restore default WinRM configurations:
winrm reset - Next, check the registered shells on your system by running:
winrm e winrm/config/Shell - Ensure that the default shell URI (
http://microsoft.com) is active and has not been overwritten by a broken custom plugin.
Step 5: Run System File Checker (SFC)
If internal Windows components responsible for processing WS-Management requests are corrupted, the SFC tool will repair them.
- Open Command Prompt as an Administrator.
- Type the following command and press Enter:
sfc /scannow - Wait for the scan to reach 100% completion.
- Restart your computer and try the WinRM connection again.
There may be some errors. Learn Microsoft