13 lines
No EOL
578 B
PowerShell
13 lines
No EOL
578 B
PowerShell
function Get-NetStat {
|
|
Get-NetTCPConnection -State Established,Listen | Sort-Object -Descending State |
|
|
Select-Object @{name="ProcessName";expression={(Get-Process -Id $_.OwningProcess).ProcessName}},
|
|
LocalAddress,
|
|
LocalPort,
|
|
RemotePort,
|
|
@{name="RemoteHostName";expression={((nslookup $_.RemoteAddress)[3]) -replace ".+:\s+"}},
|
|
RemoteAddress,
|
|
State,
|
|
CreationTime,
|
|
@{Name="RunTime"; Expression={((Get-Date) - $_.CreationTime) -replace "\.\d+$"}},
|
|
@{name="ProcessPath";expression={(Get-Process -Id $_.OwningProcess).Path}}
|
|
} |