Created
April 3, 2019 19:05
-
-
Save R41D3NN/8ddb1cc61495a0ecdd3af6ec3b0f5583 to your computer and use it in GitHub Desktop.
Does what Get-NetTCPConnection does but with gets the associated process name too.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Get-NetTCPConnection | %{ | |
$obj = New-Object -TypeName psobject; | |
$obj | Add-Member -MemberType NoteProperty -Name LocalAddress -Value $_.LocalAddress; | |
$obj | Add-Member -MemberType NoteProperty -Name LocalPort -Value $_.LocalPort | |
$obj | Add-Member -MemberType NoteProperty -Name RemoteAddress -Value $_.RemoteAddress; | |
$obj | Add-Member -MemberType NoteProperty -Name RemotePort -Value $_.RemotePort; | |
$obj | Add-Member -MemberType NoteProperty -Name State -Value $_.State; | |
$obj | Add-Member -MemberType NoteProperty -Name ProcessName -Value (Get-Process -Id $_.OwningProcess).ProcessName; | |
$obj } | Format-Table -AutoSize |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment