Skip to content

Instantly share code, notes, and snippets.

@adi928
Created February 19, 2026 07:22
Show Gist options
  • Select an option

  • Save adi928/c9b1d06637eed06e9f7f19fc91620ae7 to your computer and use it in GitHub Desktop.

Select an option

Save adi928/c9b1d06637eed06e9f7f19fc91620ae7 to your computer and use it in GitHub Desktop.
Simple script to determine top processes consuming cpu.
while($true) {
Clear-Host
Write-Host "--- TOP 15 PROCESSES (CPU USAGE) ---" -ForegroundColor Cyan
Get-Process | Sort-Object CPU -Descending | Select-Object -First 15 -Property Name, Id, @{Name="CPU(s)";Expression={$_.CPU}}, @{Name="RAM(MB)";Expression={[math]::Round($_.WorkingSet / 1MB, 2)}} | Format-Table -AutoSize
Write-Host "`n--- ACTIVE NETWORK CONNECTIONS ---" -ForegroundColor Yellow
Get-NetTCPConnection -State Established | Select-Object LocalAddress, LocalPort, RemoteAddress, RemotePort,
@{Name="Process";Expression={(Get-Process -Id $_.OwningProcess -ErrorAction SilentlyContinue).Name}},
@{Name="PID";Expression={$_.OwningProcess}} | Select-Object -First 10 | Format-Table -AutoSize
Write-Host "`n[Press Ctrl+C to Exit] - Refreshing every 3 seconds..." -ForegroundColor Gray
Start-Sleep -Seconds 3
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment