Skip to content

Instantly share code, notes, and snippets.

@junxy
Created November 25, 2016 10:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save junxy/b54d0eecf2e8d3ecefd4d2fea39d61d9 to your computer and use it in GitHub Desktop.
Save junxy/b54d0eecf2e8d3ecefd4d2fea39d61d9 to your computer and use it in GitHub Desktop.
批量ping,并输出ping不通的ip
$stringlist =
'192.168.36.104',
'192.168.36.130',
'192.168.22.126',
'192.168.50.111',
'192.168.36.129',
'192.168.36.133'
# http://ilovepowershell.com/2010/04/13/powershell-how-to-ping-computers/
$ping = new-object system.net.networkinformation.ping
$pingreturns = [ordered]@{}
foreach ($entry in $stringlist) {
$pingreturns.Add($entry, $ping.send($entry).Status)
}
$pingreturns.GetEnumerator() | ?{ $_.Value -eq "TimedOut" }
@junxy
Copy link
Author

junxy commented Nov 25, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment