PowerShell function to parse Netstat output and return a PowerShell object


This is a function to parse Netstat -ano output and return a PowerShell object.

This output is similar to that of the Get-NetTCPConnection cmdlet of the NetTCPIP PowerShell module.

To see the built-in help, type in: help Parse-Netstat -Show

Example:

(Parse-Netstat | where { $_.Version -eq ‘IPv4’ -and $_.RemoteAddress -ne ‘0.0.0.0’ -and $_.LocalPort -eq 5985 } | select RemoteAddress -Unique).RemoteAddress

This example checks for connections where localhost is listening on TCP port 5985 (VMM Agent which uses WBEM WS-Management HTTP), and returns the IP address of the remote host (VMM server). VMM being System Center Virtual Machine Manager. If it returns nothing, this means this machine is not listening on port 5985 (VMM agent not running)

Example:

vmm1

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s