Managing remote PowerShell v 3.0 hosts

I've just spent a few days banging my head of the keyboard trying to get a simple powershell script working across our environment and having sussed the problems thought I'd share and try to ease someone else's pain.


The problem manifested itself when my fully working monitor template worked on some server and failed horribly on others. The monitors get returned the lovely "No Output" message, telling you the square root of bugger all. Even when I copied the scripts over and run them locally they were still failing.


I found the Solarwinds Technical Reference Guide: Configuring and Integrating PowerShell which has the commnads for allowing remote connections, but the later part of the command (instructing the host to allow connection from the Orion server) failed with syntax errors:


> winrm set winrm/confog/client @{TrustedHosts="Orion IP address"}

     Error: Invalid use of command line. Type "winrm -?" for help.


Searching of these errors proved pretty damn fruitless, as did the reasons to why it might be failing, until I checked the versions:


> $PSVersionTable

Name                           Value

----                           -----

WSManStackVersion              3.0

PSCompatibleVersions           {1.0, 2.0, 3.0}


BuildVersion                   6.2.9200.16481

PSVersion                           3.0 <-- Not V 2.0 as required by APM PowerShell.

CLRVersion                     4.0.30319.1008

PSRemotingProtocolVersion      2.2


By luck I came across a TechNet article on "How to start a remote session with the Windows PowerShell 2.0 Engine"

     Starting the Windows PowerShell 2.0 Engine

This detailed how you could force incoming connection to use a specific version of PowerShell and within seconds, my remote scripts were working!


2> register-PSSessionConfiguration -Name PS2 -PSVersion 2.0


     WARNING: Register-PSSessionConfiguration restarts the WinRM service and all dependent services.

     All WinRM sessions connected to Windows PowerShell session configurations, such as Microsoft.PowerShell and session configurations that are created with the Register-PSSessionConfiguration      cmdlet, are disconnected.



     Are you sure you want to perform this action?

     Performing operation "Register-PSSessionConfiguration" on Target "Name: PS2 <blah>

     This will allow selected users to remotely run Windows PowerShell commands on this computer".

     [Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"): Y


Once done my scripts ran error free!


Hope it helps someone else!

Parents Reply Children
No Data