How to check Paging Memory on swap for Windows, via command line?

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

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)