administration, powershell,

netstat for Powershell

agowa338 agowa338 Sep 24, 2016 · 1 min read
Share this

If you cannot use "Get-NetTCPConnection" here is the same using the good old "netstat -a" ;-)

 netstat -a | Select-Object -Skip 3
  | ForEach-Object {$_ -replace '\s+', ' '} | ForEach-Object {$_ -replace
  'Lokale Adresse','Lokale_Adresse'} | ForEach-Object {$_ -replace '^ ', ''} |
  ConvertFrom-Csv -Delimiter " " netstat -a | Select-Object -Skip 3 |
  ForEach-Object {$_ -replace '\s+', ' '} | ForEach-Object {$_ -replace 'Lokale
  Adresse','Lokale_Adresse'} | ForEach-Object {$_ -replace '^ ', ''} |
  ConvertFrom-Csv -Delimiter " " | Where-Object {($_.Remoteadresse -notlike
  "$env:computername*") -and ($_.Remoteadresse -ne "*:*")} 

agowa338
Written by agowa338