powershell : Testing if port or computer is up
Found out a quick and dirty way to test if a computer is up is using the following script :-
Notice that i am using Test-NetConnection which is readily available in Powershell.
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 IsConnectionActive($Port) | |
{ | |
$result = Test-NetConnection -Port $Port -ComputerName "localhost" | |
return $result.TcpTestSucceeded | |
} |
Comments