In this blog post, Brian Posey highlighted Windows PowerShell as an essential Windows networking skill going forward. In a new series of blog posts, we will highlight existing networking-based Windows PowerShell scripts in the Script Center Repository on TechNet and show how they can be used for basic or advanced networking capabilities either at the Windows PowerShell command prompt or within your own custom scripts.
This Windows PowerShell script in the Script Center Repository tests a TCP or UDP port through the Test-Port function with the following parameters:
-computer: Specifes the computer or computers to test.
-port: Specifes the port number.
-tcp: Specifies that you want to test a TCP port.
-udp: Specifies that you want to test a UDP port
-tcptimeout: Specifies how long to wait in milliseconds when testing a TCP port.
-udptimeout: Specifies how long to wait in milliseconds when testing a UDP port.
You can test Test-Port by copying the code into the Windows PowerShell command prompt (click Copy Code on the script page, then right-click in the Windows PowerShell command prompt to paste it in). Once entered as a function, you can use the Test-Port function directly from the command line (example: PS C:\users\default> test-port -computer dc1 -port 389 -tcp). Alternately, paste this code into your Windows PowerShell script.
For those of you honing your Windows PowerShell scripting skills, notice how this script includes a thorough comment section at the beginning clearly describing each parameter and giving lots of examples.
Windows Server Information Experience