top of page

PowerShell - List ALL TCP/UDP ports local machine

  • Writer: Jon Boyette
    Jon Boyette
  • Mar 1, 2022
  • 1 min read

Save as NetStatProcessName.ps1, this particular discovery ALSO lists the processes associated with the ports.

$netstat = netstat -aon | Select-String -pattern "(TCP|UDP)"

$processList = Get-Process


foreach ($result in $netstat) {

$splitArray = $result -split " "

$procID = $splitArray[$splitArray.length – 1]

$processName = $processList | Where-Object {$_.id -eq $procID} | select processname

$splitArray[$splitArray.length – 1] = $procID + " " + $processName.processname

$splitArray -join " "

}


 
 
 

Recent Posts

See All
PowerShell - List All Domain SPNs

Save as same List_ALL_SPNs.ps1 or similar, this LDap calls the Domain for all Service Principal names and accounts related #Build LDAP...

 
 
 
PowerShell - Start-Monitoring

This is a great script used to Monitor and Email if a server is up or down, once ran, and smtp and from address is set, then run:...

 
 
 

Comments


Post: Blog2 Post
  • Facebook
  • Twitter
  • LinkedIn

©2022 by Boyette Technical Services. Proudly created with Wix.com

bottom of page