PowerShell Remoting WinRM

When trying to enter a PowerShell session on a remote PC

you receive the following error:

Enter-PSSession : Connecting to remote server win7-pc01 failed with the following error message : The client cannot connect to the destination specified in the request. Verify that the service on the destination is running and is accepting requests. Consult the logs and documentation for the WS-Management service running on the destination, most commonly IIS or WinRM. If the destination is the WinRM service, run the following command on the destination to analyze and configure the WinRM service: "winrm quickconfig". For more information, see the about_Remote_Troubleshooting Help topic. At line:1 char:1 + Enter-PSSession win7-pc01 + ~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (win7-pc01:String) [Enter-PSSession], PSRemotingTransportException + FullyQualifiedErrorId : CreateRemoteRunspaceFailed

Go to the client computer and check to see if the WinRM service is running.

Status Name DisplayName ------ ---- ----------- Running WinDefend Windows Defender Running WinHttpAutoProx... WinHTTP Web Proxy Auto-Discovery Se... Running Winmgmt Windows Management Instrumentation Stopped WinRM Windows Remote Management (WS-Manag...

We need to start the WinRM service, run:

After that has completed, check the service is running by:

PS C:\> Start-Service -Name WinRM -Verbose VERBOSE: Performing operation "Start-Service" on Target "Windows Remote Management (WS-Management) (WinRM)". PS C:\> Get-Service -Name WinRM  Status   Name               DisplayName ------   ----               ----------- Running  WinRM              Windows Remote Management (WS-Manag...

Now we have to configure WinRM to recieve remote requested. Run:

Answer Y to the questions. You’ll set the service to start when the PC is booted up, create a listener to “listen” for WinRM requests and configure the Windows firewall to allow the WinRM traffic.

WinRM quickconfig

If you check your inbound connections on your firewall you’ll see the new rules added.
WinRM firewall settings after running winrm quickconfig

We should now be able to remotely connect to the client PC via PowerShell and run all the PowerShell commands on it:

PS C:\> Enter-PSSession -ComputerName win7-pc01 [win7-pc01]: PS C:\Users\administrator\Documents>

Hope this has helped.

Please note
This was done on my test network. Make sure you know the implications of opening up firewall ports and running WinRM on you PC(s).

For this post my test lab consists of a Windows Server 2012 R2 GC DC and a Windows 7 Enterprise client.