Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save SQLDBAWithABeard/1fb7419b010a48b322735dd806c3c3e4 to your computer and use it in GitHub Desktop.
Save SQLDBAWithABeard/1fb7419b010a48b322735dd806c3c3e4 to your computer and use it in GitHub Desktop.
All hail Lee Holmes - This is his Test-PSRemoting function
function Test-PsRemoting
{
# Written by Lee Holmes - http://www.leeholmes.com/blog/2009/11/20/testing-for-powershell-remoting-test-psremoting/
param(
[Parameter(Mandatory = $true)]
$computername
)
try
{
$errorActionPreference = "Stop"
$result = Invoke-Command -ComputerName $computername { 1 }
}
catch
{
Write-Verbose $_
return $false
}
## I've never seen this happen, but if you want to be
## thorough....
if($result -ne 1)
{
Write-Verbose "Remoting to $computerName returned an unexpected result."
return $false
}
$true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment