Quick tip this one, and indeed one which solves a pretty simple issue when trying to remote to a server which has Powershell v2.0 installed.
To give you a very quick overview I have been writing a few scripts for Exchange which execute both locally and on remote machines to perform certain tasks (where the remote execution takes advantage of the secure remote management features which Powershell v2.0 provides via WinRM). The Servers which I have been using these scripts on are Windows 2008 based with Exchange 2007.
Initially when executing the remote portions of my scripts (at the point where I attempt to establish a remote Powershell session to one of the servers) I would receive the following error message:
PS C:\> New-PSSession -ComputerName lab-dc-01 [lab-dc-01] Connecting to remote server 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. + CategoryInfo : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) , PSRemotingTransportException + FullyQualifiedErrorId : PSSessionOpenFailed PS C:\>
Both the source and remote machine both had Powershell v2.0 installed and I had not seen the problem with Exchange 2010 based machines.
Funnily enough the solution to this problem was contained within the error itself – in essence on the remote machine opening a command window and typing in “winrm quickconfig” did indeed solve the problem – see below;
Upon pressing I was presented with the following message – to which I answered “y” for “yes” – see below;
The WinRM configuration tool then went away and configured the relevant Firewall and HTTP service point entries – see below;
However here arose another question – why do remote sessions work in Exchange 2010 with PS v2.0 installed?
Well from what I can ascertain; when you install Exchange 2010 – you will be aware that PS v.2.0 is a setup prerequisite; the installation of Exchange 2010 configures the remote access features automatically.
However if (like me in this example) upgrade Powershell to version 2.0 from 1.0 on a System with Exchange 2007 you have to manually enable remote sessions via the above command.
I hope that this helps someone out.