Last active
November 1, 2016 01:22
-
-
Save mbrownnycnyc/9913361 to your computer and use it in GitHub Desktop.
test-connection got you down? ping just not cutting it for you? How about using the System.Net.NetworkInformation.Ping.send() method
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
# with reference to http://theadminguy.com/2009/04/30/portscan-with-powershell/ | |
function fastping{ | |
[CmdletBinding()] | |
param( | |
[String]$computername = "127.0.0.1", | |
[int]$delay = 100 | |
) | |
$ping = new-object System.Net.NetworkInformation.Ping | |
# see http://msdn.microsoft.com/en-us/library/system.net.networkinformation.ipstatus%28v=vs.110%29.aspx | |
try { | |
if ($ping.send($computername,$delay).status -ne "Success") { | |
return $false; | |
} | |
else { | |
return $true; | |
} | |
} catch { | |
return $false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks a lot. This helped me when the Test-connection cmdlet could not be found on my system anymore (not sure how that happened). Thanks again