---
title: PowerShell Remote Connection Testing: Practical Examples
description: Master remote connection testing with PowerShell using Test-NetConnection and Test-Connection.
canonical: https://adamtheautomator.com/powershell-test-remote-connection/
---

# PowerShell Remote Connection Testing: Practical Examples

> Master remote connection testing with PowerShell using Test-NetConnection and Test-Connection.

Source: https://adamtheautomator.com/powershell-test-remote-connection/

---

- PowerShell Remote Connection Testing: Practical Examples Tap to hide Home

- Tutorials

- Guidebooks

- Instructors

- Get Paid to Write

- Advertising

- Recommended Resources

- About Adam

                Search for:

-

-

-

-

# PowerShell Remote Connection Testing: Practical Examples

        Published:25 July 2019 - 3 min. read

- PowerShell

          [](https://adamtheautomator.com/author/matt/)

            [Matt Browne](https://adamtheautomator.com/author/matt/)

            Read [more tutorials](https://adamtheautomator.com/author/matt/) by Matt Browne!

        [](https://specopssoft.com/product/specops-password-auditor/?utm_source=adamtheautomator&utm_medium=referral&utm_campaign=adamtheautomator_referral_na&utm_content=display)
        Audit Active Directory for stale users, weak passwords, and other security risks with [Specops Password Auditor](https://specopssoft.com/product/specops-password-auditor/?utm_source=adamtheautomator&utm_medium=referral&utm_campaign=adamtheautomator_referral_na&utm_content=text).

Table of Contents

- PowerShellified Ping?
- Test-Connection
- Test-NetConnection
- Summary

                XFacebookLinkedIn

Pinging a device is a basic skill of any system administrator, and we all know the ping.exe command but have you heard of the PowerShell commands Test-Connection and Test-NetConnection? It's PowerShell's way of injecting the old-school [ping.exe command](https://docs.microsoft.com/en-us/troubleshoot/windows-client/networking/ping-exe-check-microsoft-broadband-network-adapter) with steroids! Let's break out some PowerShell to test a remote connection and more in this blog post.

Pinging a computer is really easy to do in [PowerShell but there are a set of options](https://adamtheautomator.com/powershell-scheduled-task/) that really make it useful, and take it way beyond what ping can do.

## PowerShellified Ping?

Although old-school ping is a legacy tool, it's still around and can be invoked with PowerShell just like any other cmd utility can. It can be executed either directly by typing ping <hostname> or you can also use the [Invoke-Expression](https://adamtheautomator.com/invoke-expression/) cmdlet to call ping.exe but this is just putting lipstick on a pig.

PS51> Invoke-Expression -Command "ping.exe google.com"

Invoke-Expression example

This works and you'll get the normal ping results back, but it's a bit clunky and all you get is the text output from the ping command. Let's use the native PowerShell cmdlet [Test-Connection](https://adamtheautomator.com/powershell-test-connection/) instead.

## Test-Connection

PS51> Test-Connection www.google.com

Running Test-Connection

That's a much more native way of doing it in PowerShell, and it returns an object rather than just the text output of ping.exe.

If you pipe the object coming from the PowerShell Test-Connection cmdlet into Select-Object -Property * we get a mass of useful information.

PS51> Test-Connection www.google.com | Select-Object -Property *

Inspecting all object properties returned from Test-Connection

Like any good PowerShell cmdlet we have switches so we can set things like Count for the number of attempts, BufferSize for the size of the packet and Delay to define the delay between each attempt and use PowerShell to test a remote connection like a boss.

PS51> Test-Connection www.google.com -Count 2 -BufferSize 128 -Delay 3

There are a lot of other parameters you can use but I'm not going to go through them all. But there are some parameters that are useful like Source. The Source parameter makes it possible to use the PowerShell Test-Connection cmdlet to connect to other machines on your network and initiate connection attempts from there.

PS51> Test-Connection -Source "LocalHost", "TestVM01", "TestVM02" -ComputerName "www.google.com"

Testing connection on multiple hosts with the Source parameter

The output shows all the results from the hosts in the source list, in one nice neat table containing objects. This is especially useful if you have a complicated network with lots of firewalls between you and the target. As long as you can get to those source machines then you can test any of the connections from there.

The Quiet parameter goes the other way and gives a really simple true/false result. This is super useful when using it in if statements.

PS51> Test-Connection www.google.com -Quiet

Using the Quiet parameter

If you have a lot of targets to test then the AsJob parameter might be useful for putting the list to a background job and getting the results using Get-Job | Receive-Job.

PS51> Test-Connection google.com -count 10 -AsJob
PS51> Get-Job | Receive-Job

Using Test-Connection with a background job

## Test-NetConnection

Another cmdlet to look at is [Test-NetConnection](https://adamtheautomator.com/test-netconnection/). The Test-NetConnection cmdlet can test the connection to a device much like the PowerShell Test-Connection cmdlet but it's a little more networking focused. In the simplest sense, it gives much the same results.

PS51> Test-NetConnection www.google.com

Using Test-NetConnection

Again this cmdlet has a load of really useful parameters like Port to test whether a remote port is open or not.

PS51> Test-NetConnection www.google.com -Port 80

Testing port connectivity

With the TraceRoute parameter you can do the same as you would with [tracert](https://adamtheautomator.com/traceoute-windows-10/).exe, but the output is a PowerShell object with each of the hops on the route to the target.

PS51> Test-NetConnection www.google.com -TraceRoute

Using Test-NetConnection for tracing routes

Again, if you want to use PowerShell cmdlet Test-NetConnection in an if statement to test if a device has port 80 open you can use the -InformationLevel Quiet parameter/value to give you a simple true/false result from the test.

PS51> Test-NetConnection www.google.com -port 80 -InformationLevel Quiet

If you'd like an advanced example of using these cmdlets, I highly encourage you to check out the post [An All-in-One PowerShell Server Port Testing Tool](https://adamtheautomator.com/powershell-test-port/).

## Summary

Whether you choose to use the PowerShell Test-Connection cmdlet or Test-NetConnection cmdlet, we've got you covered! Using one or both of these cmdlets will allow you to use PowerShell to test a remote connection with no problem at all many different ways!

  Hate ads? Want to support the writer? Get many of our tutorials packaged as an ATA Guidebook.

  [Explore ATA Guidebooks](https://adamtheautomator.com/ata-guidebooks/)

## More from ATA Learning and Partners

- ### Recommended Resources! Recommended Resources for Training, Information Security, Automation, and more!

- ### Get Paid to Write! ATA Learning is always seeking instructors of all experience levels. Regardless if you’re a junior admin or system architect, you have something to share. Why not write on a platform with an existing audience and share your knowledge with the world?

- ### ATA Learning Guidebooks ATA Learning is known for its high-quality written tutorials in the form of blog posts. Support ATA Learning with ATA Guidebook PDF eBooks available offline and with no ads!

## Categories

- IT Ops

- Cloud

- DevOps

- Home Ops

- Information Security

- Software Development

## Site

- Home

- Tutorials

- Guidebooks

- Instructors

- Get Paid to Write

- Advertising

- Recommended Resources

- About Adam

        Copyright 2026&copy; ATA Learning | [Privacy Policy](https://adamtheautomator.com/privacy/)

                                                        Don't be left behind with the ATA Learning Newsletter!

Looks like you're offline!
