Skip to content

Instantly share code, notes, and snippets.

@iamazeem
Last active July 31, 2023 14:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iamazeem/2d9cbc2e79878cabbfe85d704324be2e to your computer and use it in GitHub Desktop.
Save iamazeem/2d9cbc2e79878cabbfe85d704324be2e to your computer and use it in GitHub Desktop.
Get local listening ports as CSV on Windows
((Get-NetTCPConnection -State Listen | Select-Object -Property LocalPort | ConvertTo-csv -NoTypeInformation | Select-Object -skip 1) -join ",") -replace '"'
# List IPv4 listening local ports
(Get-NetTCPConnection -State Listen | Where-Object -Property LocalAddress -NotContains '::' | Select-Object -Property LocalPort | ConvertTo-csv -NoTypeInformation | Select-Object -skip 1 -Unique) -replace '"'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment