Skip to content

Instantly share code, notes, and snippets.

@b3nj1-1
Created September 16, 2022 01:45
Show Gist options
  • Save b3nj1-1/682b9e63c8270cd02518441a29099fd8 to your computer and use it in GitHub Desktop.
Save b3nj1-1/682b9e63c8270cd02518441a29099fd8 to your computer and use it in GitHub Desktop.
Check Usage in Powershell
$totalRam = (Get-CimInstance Win32_PhysicalMemory | Measure-Object -Property capacity -Sum).Sum
while($true) {
$date = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
$cpuTime = (Get-Counter '\Processor(_Total)\% Processor Time').CounterSamples.CookedValue
$availMem = (Get-Counter '\Memory\Available MBytes').CounterSamples.CookedValue
$date + ' > CPU: ' + $cpuTime.ToString("#,0.000") + '%, Avail. Mem.: ' + $availMem.ToString("N0") + 'MB (' + (104857600 * $availMem / $totalRam).ToString("#,0.0") + '%)'
Start-Sleep -s 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment