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.

function IsConnectionActive($Port)
{
$result = Test-NetConnection -Port $Port -ComputerName "localhost"
return $result.TcpTestSucceeded
}




Comments

Popular posts from this blog

The specified initialization vector (IV) does not match the block size for this algorithm

NodeJS: Error: spawn EINVAL in window for node version 20.20 and 18.20