The Test-PowerShellConnectivity cmdlet can be used to verify that PowerShell remoting is functioning correctly.

Running the cmdlet will test the local server.

[PS] C:>Test-PowerShellConnectivity

CasServer  LocalSite     Scenario        Result  Latency(MS)
---------  ---------     --------        ------  -----------
E15MB1     Sydney        Logon User      Success      312.50

You can also test a remote server.

[PS] C:>Test-PowerShellConnectivity E15MB3

CasServer  LocalSite     Scenario        Result  Latency(MS)
---------  ---------     --------        ------  -----------
E15MB3     Sydney        Logon User      Success      140.63

And you can use the pipeline to test multiple servers together.

[PS] C:>Get-ExchangeServer | Test-PowerShellConnectivity

CasServer  LocalSite     Scenario        Result  Latency(MS)
---------  ---------     --------        ------  -----------
E15MB1     Sydney        Logon User      Success      203.12
E15MB2     Sydney        Logon User      Success      218.79
E15MB3     Sydney        Logon User      Success      187.51

Although this may not be useful for ad-hoc situations it can come in handy when writing scripts. You can use Test-PowerShellConnectivity before running a series of other cmdlets that rely on remoting.

param(
	[Parameter( Mandatory=$true)]
	[string]$server
)


#Check Powershell Connectivity first
if ((Test-PowerShellConnectivity $server).Result.Value -eq "Success")
{
    Write-Host "PowerShell connectivity test successful"
    #Run other commands
}
else
{
    Write-Host "PowerShell connectivity test failed"
}

About the Author

Paul Cunningham

Paul is a former Microsoft MVP for Office Apps and Services. He works as a consultant, writer, and trainer specializing in Office 365 and Exchange Server. Paul no longer writes for Practical365.com.

Leave a Reply