function Get-NetworkStatistics { [OutputType(‘System.Management.Automation.PSObject’)] [CmdletBinding(DefaultParameterSetName=’name’)] param( [Parameter(Position=0,ValueFromPipeline=$true,ParameterSetName=’port’)] [System.String]$Port=’*’, [Parameter(Position=0,ValueFromPipeline=$true,ParameterSetName=’name’)] [System.String]$ProcessName=’*’, [Parameter(Position=0,ValueFromPipeline=$true,ParameterSetName=’address’)] [System.String]$Address=’*’, [Parameter()] [ValidateSet(‘*’,’tcp’,’udp’)] [System.String]$Protocol=’*’, [Parameter()] [ValidateSet(‘*’,’Closed’,’CloseWait’,’Closing’,’DeleteTcb’,’Established’,’FinWait1′,’FinWait2′,’LastAck’,’Listen’,’SynReceived’,’SynSent’,’TimeWait’,’Unknown’)] [System.String]$State=’*’ ) begin { $properties = ‘Protocol’,’LocalAddress’,’LocalPort’ $properties += ‘RemoteAddress’,’RemotePort’,’State’,’ProcessName’,’PID’ } process { netstat -ano | Select-String -Pattern ‘\s+(TCP|UDP)’ | ForEach-Object { $item = $_.line.split(‘ ‘,[System.StringSplitOptions]::RemoveEmptyEntries) if($item[1] -notmatch ‘^\[::’) { if (($la =…