How to check Paging Memory on swap for Windows, via command line?
26,582
Solution 1
try this:
systeminfo | find "Virtual Memory"
this will return:
Virtual Memory: Max Size: 17.297 MB
Virtual Memory: Available: 7.186 MB
Virtual Memory: In Use: 10.111 MB
here is my powershell script that returns swap usage:
$maxSizeStr = systeminfo | select-string "Virtual Memory: Max Size:"
$maxSize = [int][regex]::Matches($maxSizeStr, '[\d.]+').Value -replace "\.",""
$inUseStr = systeminfo | select-string "Virtual Memory: In Use:"
$inUse = [int][regex]::Matches($inUseStr, '[\d.]+').Value -replace "\.",""
$swapUsage = ($inUse / $maxSize) * 100
Write-Output $swapUsage
Solution 2
Is my powershell script returns swap usage
$colItems = get-wmiobject -class "Win32_PageFileUsage" -namespace "root\CIMV2" -computername localhost
foreach ($objItem in $colItems) {
$allocate = $objItem.AllocatedBaseSize
$current = $objItem.CurrentUsage
}
write-host ($allocate - $current)
Related videos on Youtube
![Admin](/assets/logo_square_200-5d0d61d6853298bd2a4fe063103715b4daf2819fc21225efa21dfb93e61952ea.png)
Author by
Admin
Updated on September 18, 2022Comments
-
Admin almost 2 years
On Windows operating systems, we use the Resource Monitor to check the memory paging for my server.
I need to check it via command line so I can put in my standard script to check and create text log files.
Is there a way to check the paging memory on swap for windows, but via command line?
-
SuperSafie almost 6 yearsThis returns different values than the PowerShell commands @DavidPostill suggested. Maybe running both with a just rebooted system with lots of RAM can tell which one is right
-
DavidPostill almost 4 yearsYour answer would be better if you included some example output.