debugging port problems

debugging port problems

function Get-NetworkStatistics { [OutputType(‘System.Management.Automation.PSObject’)] [CmdletBinding()] param( [Parameter(Position=0)] [System.String]$ProcessName=’*’, [Parameter(Position=1)] [System.String]$Address=’*’, [Parameter(Position=2)] $Port=’*’, [Parameter(Position=3, ValueFromPipeline = $True, ValueFromPipelineByPropertyName = $True)] [System.String[]]$ComputerName=$env:COMPUTERNAME, [ValidateSet(‘*’,’tcp’,’udp’)] [System.String]$Protocol=’*’, [ValidateSet(‘*’,’Closed’,’Close_Wait’,’Closing’,’Delete_Tcb’,’DeleteTcb’,’Established’,’Fin_Wait_1′,’Fin_Wait_2′,’Last_Ack’,’Listening’,’Syn_Received’,’Syn_Sent’,’Time_Wait’,’Unknown’)] [System.String]$State=’*’, [switch]$ShowHostnames, [switch]$ShowProcessNames = $true, [System.String]$TempFile = “C:\netstat.txt”, [validateset(‘*’,’IPv4′,’IPv6′)] [string]$AddressFamily = ‘*’ ) begin{ #Define properties $properties = ‘ComputerName’,’Protocol’,’LocalAddress’,’LocalPort’,’RemoteAddress’,’RemotePort’,’State’,’ProcessName’,’PID’ #store hostnames in array for quick lookup $dnsCache = @{} } process{ foreach($Computer […]