PowerShell 2.0 Answers Life’s Big Questions!

Is there anybody out there? Are we alone in the universe? Are my computers online? PowerShell 2.0 can tell you! (At least that last one.)

So the boss emails you a list of computers and wants you to check if each of them are available on the network. You could open a command prompt, type PING and the first name, wait for a response, PING the second, ad nauseum. If there’s two names on the list, fine. How many on this list? 183. Yuck! Sounds like a job for… PowerShell!


Okay — let’s find a PowerShell feature that lets me ping a computer. Get-Command is the usual way to go about that, but in this case, I’m not getting a lot of luck. I see the PING executable, and other stuff I don’t need, but nothing in PowerShell. Here’s a wild idea — let’s try using Get-Help and see what we find.

Interesting — there’s a Test-Connection cmdlet that claims to be able to send PINGs to one or more computers. Sounds perfect. Let’s take a close look at the help file for Test-Connection.

I like the idea of the –Quiet parameter for a simple TRUE/FALSE evaluation of whether the computer is on the network. Having an object to interrogate might be useful in a later script, but for now, I’ll leave that Win32_PINGSTATUS object alone. What I really want to do is get a list of which computers are not currently accessible. So strategically, I want to iterate through my list of computer names, and for each one of them, if it isn’t ping-able (is that a word? Is now) then I want to get a message that says so. So how about something like this (click on the screenshot for a larger image)?

It’s a good start. But I don’t know which of the computers from my file are the ones returning true and false. Also, let’s assume I only want to know which computers are offline. Time to pull out the trusty old ‘if’ statement.

Hmmm. Those pesky rebels are at it again, it seems.

I like the output of this little one-liner. It’s a little slow, though. I can tweak it a bit by adding the –Count 1 parameter to Test-Connection, which instead of launching 4 ICMP packets sends One Ping Only (now, why am I hearing Sean Connery’s voice in my head all of a sudden?)

In this article

Join the Conversation


  1. Mike Hammond Reply

    Comments and questions are, as usual, most welcome.

  2. Awaize Reply

    Hi Mike,

    I took a course you taught back in March of this year, “Configuring, Managing and Maintaining Windows Server 2008 Servers” and I lost your email address. I had a question about Windows 2008 R2 power user groups. We built a W2K8 R2 server and added 2 groups to power users groups so they can start/stop/restart services, but when they try the options are greyed out. I wanted to know how I can get around this so they can do those functions.

  3. Mike Hammond Reply

    Hi Awaize, good to hear from you. The best way to accomplish that is through Group Policy. Take a look at this KB article from Microsoft. It’s discussing Server 2003, but it should still be relevant for Server 2008 R2

  4. Mike Hammond Reply

    Whoops – here’s the link:

    How To Configure Group Policies to Set Security for System Services in Windows Server 2003