Skip to content

Instantly share code, notes, and snippets.

@efeozyer
Created June 6, 2020 07:47
Show Gist options
  • Save efeozyer/5ab81ae72e8a293aa2e46f8cbd91e909 to your computer and use it in GitHub Desktop.
Save efeozyer/5ab81ae72e8a293aa2e46f8cbd91e909 to your computer and use it in GitHub Desktop.
Powershell System Resources
$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