Cause:
This would occur for below reason:
1) When target host is not reachable
2) When Domain controller machine is not reachable [ For domain machines]
3) When “WinRM” service disabled in the target host
4) When PSRemoting disabled in the target host
Solution:
1) Go to Windows Powershell with elevated permission and execute below query:
Enable-PSRemoting
To check if the PSRemoting is enabled by using below command;
Enter-PSSession -ComputerName localhost
2) Go to Services(Run -> services.msc) and restart the Windows Remote Management Service(WinRM)
- In case if it is disabled or stopped, set the Start Type as Automatic and Start the service
You can enable the WS-Management protocol on the local computer, and set up the default configuration for remote management with the command below;
winrm quickconfig
3) Add an Inbound Exception Rule in Windows Firewall for WinRm(for HTTP only) for both Public and Domain
- Go to WindowsFirewall->Advanced Settings
- Select Inbound Exception Rules->Predefined rules
- Allow the connection and click ok