Monday, January 19, 2009

ping with Win32_PingStatus class

[] to ping against a computer (Address, ResponseTime)

PS> Get-WmiObject -Class Win32_PingStatus -Filter "Address='127.0.0.1'" -ComputerName .
| Format-Table -Property Address,ResponseTime,StatusCode -Autosize

[] to ping all of the computers on a subnet

PS> 1..254
| ForEach-Object -Process {Get-WmiObject -Class Win32_PingStatus -Filter ("Address='192.168.1." + $_ + "'") -ComputerName .}
| Select-Object -Property Address,ResponseTime,StatusCode

Private network number (192.168.1.0) and Class C subnet mask (255.255.255.0)

No comments:

Post a Comment