I am having problems getting the to return false when it cannot find an RPC connection to a machine. The snippet is below even if the port connection is successful and returns true it still goes to the else and reports issue with RPC. Any thoughts on this please ?
$connection = Test-netconnection -ComputerName $ComputerName -port 135
if ($connection -eq $true)
Write-Host “RPC Connection to Port 135 successful”