Finding Systems Online (Fast)

Using PowerShell Background Jobs, you can find a large number of online systems within only a few seconds:

function Check-Online {
param(
$computername
)
test-connection -count 1 -ComputerName $computername -TimeToLive 5 -asJob |
Wait-Job |
Receive-Job |
Where-Object { $_.StatusCode -eq 0 } |
Select-Object -ExpandProperty Address
}
$ips = 1..255 | ForEach-Object { "10.10.10.$_" }
$online = Check-Online -computername $ips
$online

This code pings an IP segment from 10.10.10.1 to 10.10.10.255 and returns only those IPs that respond.

Twitter This Tip! ReTweet this Tip!


Posted Dec 07 2010, 08:00 AM by ps1

Comments

surveyor wrote re: Finding Systems Online (Fast)
on 12-09-2010 6:49 AM

Does not work for me with more than 512 addresses. Errormessage means "Receive-Job : Datenträgerkontingentverwaltung". ???

Concentrated Tech NSoftware Dell Compellent Sponsored by Idera and Concentrated Tech and NSoftware and Dell Compellent
Copyright 2011 PowerShell.com. All rights reserved.