Advanced Windows PowerShell Scripting Video Training

Advanced Windows PowerShell Scripting Video Training
Advanced Windows PowerShell Scripting Video Training

Monday, March 12, 2012

Problem using Invoke-Command with Windows 7 client

While testing some code that used PowerShells Invoke-Command to send code to both Windows Server 2008 R2 and Windows 7, I discovered an inconsistency in the way Windows Remoting is applied to both platforms. The servers worked fine.  Even though I disabled to firewall for testing, I received this error when sending commands to the Windows 7 client:

 

[ClientName] Connecting to remote server failed with the following error message : The client cannot connect to the destingatoin 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.

+ CategoryInfo       : OpenError: (:) [], PSRemotingTransportException

+ FullyQualifiedErrorId : PSSessionStateBroken

The fix that I came up with was to deploy and Group Policy that allowed remoting and scope it to the client.

1. Open Group Policy Management console
2. Select the domain, and right-click the Default Domain Policy to edit it
3. Computer Configuration > Policies > Administrative Templates > Windows Components > Windows Remote Management > WinRM Service
4. Allow automatic configuration of listeners, put * in the IPv4 and IPv6 filter text boxes
5. Computer Configuration > Policies > Administrative Templates > Windows Components > Windows Remote Shell
6. Allow Remote Shell Access, Enabled
7. Save everything. Run Gpupdate on all servers that are currently running.

No comments: