Created
November 25, 2016 10:16
-
-
Save junxy/b54d0eecf2e8d3ecefd4d2fea39d61d9 to your computer and use it in GitHub Desktop.
批量ping,并输出ping不通的ip
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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" } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
powershell 正则表达式提取 ip地址: http://stackoverflow.com/questions/31178400/regex-to-extract-an-ip-address-from-a-string