Created
September 16, 2022 01:45
-
-
Save b3nj1-1/682b9e63c8270cd02518441a29099fd8 to your computer and use it in GitHub Desktop.
Check Usage in Powershell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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