Q: What is a good way to test whether a remote Windows PowerShell session can be created, and then if it can actually be used?

Creating and testing a remote Windows PowerShell session.

John Savill

March 29, 2012

1 Min Read
ITPro Today logo in a gray background | ITPro Today

A:The easiest way to test a remote PowerShell is to create a PowerShell session on the remote computer. You can test using a specific credential:

PS C:> New-PSSession -ComputerName savdalvmm12.savilltech.net -Credential (Get-Credential savilltechSvcMgrService)

where "savdalvmm12.savilltech.net" is replaced with your server name. The example above returns the following:

Id Name ComputerName State ConfigurationName Availability
-- ---- ------------ ----- ----------------- ------------
1 Session1 savdalvmm12.... Opened Microsoft.PowerShell Available

If this command works, it means the connection can be created. To actually see if commands can be used, use the Invoke-Command, the remote machine, anda basic command, such as that for listing folders on the C:drive:

PS C:> Invoke-Command -ComputerName savdalvmm12.savilltech.net -Credential (Get-Credential savilltechSvcMgrService) -ScriptBlock {Get-ChildItem c:}        

Typically, with this command you will see any real errors that might be stopping remote PowerShell from functioning.

A great example occurred when Iwas trying to connect Service Manager 2012 to Virtual Machine Manager (VMM) 2012. Using the command above gave me an error that explained why my TestConnection was failing at creating the connection:

[savdalvmm12.savilltech.net] Connecting to remote server failed with the following error message : The WS-Management service cannot process the request. This user is allowed a maximum number of 5 concurrent shells, which has been exceeded. Close existing shells or raise the quota for this user. For more information, see the about_Remote_Troubleshooting Help topic.+ CategoryInfo : OpenError: (:) [], PSRemotingTransportException+ FullyQualifiedErrorId : PSSessionStateBroken

Basically, for some reason the connector creation had tried to create too many sessions. A reboot of my VMM server solved the problem.

 

We do more than Windows! Check out all of John Savill's FAQs!

About the Author

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like