Created
November 28, 2017 13:46
-
-
Save SQLDBAWithABeard/1fb7419b010a48b322735dd806c3c3e4 to your computer and use it in GitHub Desktop.
All hail Lee Holmes - This is his Test-PSRemoting function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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