Pinging computers is a frequently needed task. The PowerShell cmdlets such as Test-Connection can do pings but do not have a timeout limit, so when you try and ping offline systems, it may take a long time to get a result.

WMI can ping with timeouts. Here is how:

$ComputerName = ''
$TimeoutMillisec = 1000

Get-WmiObject -Class Win32_PingStatus -Filter "Address='$ComputerName' and timeout=$TimeoutMillisec" | Select-Object -Property Address, StatusCode

A status code of 0 indicates success. Any other code indicates a failure.

Are you an experienced professional PowerShell user? Then learning from default course work isn’t your thing. Consider learning the tricks of the trade from one another! Meet the most creative and sophisticated fellow PowerShellers, along with Microsoft PowerShell team members and PowerShell inventor Jeffrey Snover. Attend this years’ PowerShell Conference EU, taking place April 17-20 in Hanover, Germany, for the leading edge. 35 international top speakers, 80 sessions, and security workshops are waiting for you, including two exciting evening events. The conference is limited to 300 delegates. More details at

Twitter This Tip! ReTweet this Tip!