Skip to main content

Test-Connection with Timeout

The Test-Connection cmdlet implements a simple ping to check whether a system responds to an ICMP request. Unfortunately, you cannot specify a timeout. Test-Connection defaults to a static timeout of 4 seconds:

PS C:> Test-Connection -ComputerName -Count 1 | Select-Object Address, ResponseTime, Timeout

Address                ResponseTime Timeout
-------                ------------ -------          118    4000 

To use a timeout, simply use the underlying WMI query like this:

$ComputerName = ''
$Count = 1
$Timeout = 1000
$Filter = 'Address="{0}" and Timeout={1}' -f $ComputerName, $Timeout
Get-WmiObject -Class Win32_PingStatus -Filter $Filter |
  Select-Object Address, ResponseTime, Timeout

Here is the result:

Address                ResponseTime Timeout
-------                ------------ -------          118    1000 

To ping multiple times, simply use a loop.

Throughout this month, we'd like to point you to two awesome community-driven global PowerShell events taking place this year:

Europe: April 20-22: 3-day PowerShell Conference EU in Hannover, Germany, with more than 30+ speakers including Jeffrey Snover and Bruce Payette, and 60+ sessions (

Asia: October 21-22: 2-day PowerShell Conference Asia in Singapore. Watch latest annoncements at

Both events have limited seats available so you may want to register early.

Twitter This Tip! ReTweet this Tip!

Posted Jan 14 2016, 06:00 AM by ps1


I am the one