Last active
November 12, 2019 16:22
-
-
Save altrive/6044589 to your computer and use it in GitHub Desktop.
PowerShell v4 new cmdlet "Test-NetConnection"
This file contains hidden or 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
| #if ComputerName is not supplied. Connect to "internetbeacon.msedge.net" by default | |
| Test-NetConnection | |
| #Test ping(ICMP protocol) | |
| Test-NetConnection "google.com" | |
| #Ping with TraceRoute | |
| Test-NetConnection "google.com" -TraceRoute | |
| #Set Remote ComputerName | |
| $target = "172.16.100.6" | |
| #Specift Port by Protocol(HTTP/SMB/RDP/WINRM) | |
| Write-Host -NoNewLine ("{0,-5} Port({1,4}): " -f "HTTP","80") | |
| Test-NetConnection -ComputerName $target -CommonTCPPort HTTP -InformationLevel Quiet | |
| Write-Host -NoNewLine ("{0,-5} Port({1,4}): " -f "SMB","445") | |
| Test-NetConnection -ComputerName $target -CommonTCPPort SMB -InformationLevel Quiet | |
| Write-Host -NoNewLine ("{0,-5} Port({1,4}): " -f "RDP","3389") | |
| Test-NetConnection -ComputerName $target -CommonTCPPort RDP -InformationLevel Quiet | |
| Write-Host -NoNewLine ("{0,-5} Port({1,4}): " -f "WINRM","5985") | |
| Test-NetConnection -ComputerName $target -CommonTCPPort WINRM -InformationLevel Quiet | |
| #Specific Port by Number | |
| Write-Host -NoNewLine ("{0,-5} Port({1,4}): " -f "Unknown","139") | |
| Test-NetConnection -ComputerName $target -Port 139 -InformationLevel Quiet |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment