PowerShell for Windows Admins

May 21 2010   12:52PM GMT

Quick ping

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

If you’ve used ping before you’ll know that it normally returns four replies from the target.  In PowerShell we have Test-Connection which does the same job. It also normally returns four replies.

When I’m working with remote machines I often want to check they are available before sending a command – especially a WMI command that can take a long time to time out.

"rslaptop01", "" | 
foreach {
    if (Test-Connection $_ -Count 1) {
        Get-WmiObject -ComputerName $_ -Class Win32_LogicalDisk `
        -Filter "DriveType=’3’" |
        select SystemName, DeviceID, Size, FreeSpace

To speed up the process use the –Count parameter on test-connection and only get 1 reply.  Quick test to see if he system is there and then run the rest of the code

 Comment on this Post

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

Share this item with your network: