Public/Test-PSRemoting.ps1
Function Test-PsRemoting { param( [Parameter( Mandatory = $true, ValueFromPipeline, ValueFromPipelineByPropertyName )] $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 } else { Return $true } } |