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)
Share:
26,582

Related videos on Youtube

Admin
Author by

Admin

Updated on September 18, 2022

Comments

  • Admin
    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
    SuperSafie almost 6 years
    This 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
    DavidPostill almost 4 years
    Your answer would be better if you included some example output.