Random Notes on Learning .NET Powershell C#. I publish as I learn. This gives the blog a scratch quality. Starting with Powershell. A script repository is at www.rmfdevelopment.com/PowerShell_Scripts
Wednesday, January 4, 2012
Parse TCP and UDP ports from services file
# Parses TCP and UDP ports from services file on Windows 7
$a=gc C:\Windows\System32\drivers\etc\services
$tcp=$a | sls tcp
$udp=$a | sls udp
[array[]]$tcp=0..(($tcp.count) -1) | % { (($tcp.GetValue($_) -split("/"))[0])}
[array[]]$udp=0..(($udp.count) -1) | % { (($udp.GetValue($_) -split("/"))[0])}
[array[]]$tcp_service_ports=0..(($tcp.count) -1) | % { (($tcp.GetValue($_) -split(" "))[-1])}
[array[]]$udp_service_ports=0..(($udp.count) -1) | % { (($udp.GetValue($_) -split(" "))[-1])}
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment