Commands / Network

Test-Connection

Ping a host

beginner Network

Test-Connection
 Test-Connection -ComputerName 1.1.1.1 -Count 2
Works on
WindowsLinuxmacOS
PowerShell
5.1 and later
Reference
Microsoft Learn: Test-Connection

What you'll see

   Destination: 1.1.1.1

Ping Source           Address                   Latency BufferSize Status
                                                   (ms)        (B)
---- ------           -------                   ------- ---------- ------
   1 MY-LAPTOP        1.1.1.1                        12         32 Success
   2 MY-LAPTOP        1.1.1.1                        11         32 Success

Ping. -Count 2 keeps it short. In PowerShell 7, -TargetName is the modern parameter name. -ComputerName still works on Windows PowerShell 5.1.

This is ICMP. A host can be up and still block ping.

Try this

Test-Connection -ComputerName localhost -Count 1

Coming from another shell

ShellWhat you might type
bash / zshping -c 2 1.1.1.1
cmd.exeping -n 2 1.1.1.1

More in From bash and From cmd.

Related commands