Get Pagefile usage of all running VM’s in inventory

Get Pagefile usage of all running VM’s in inventory

function Get-PagefileUsage {
$tabelle = @()
Get-VM | ? {$_.PowerState -like "PoweredOn"} | % { 
   $collect                =   "" | Select Name, PagefileUsage, TotalvRAM
   $collect.Name           =   $_.Name
   $collect.PagefileUsage  =   (Get-WmiObject Win32_PagefileUsage -ComputerName $_.Guest.Hostname).CurrentUsage
   $collect.TotalvRam      =   $_.MemoryMB
   $tabelle += $collect
   }
$tabelle | Export-Csv $env:userprofile\Desktop\PagefileOverview.csv
Write-Host -fore yellow "Tabelle exportiert auf den Desktop als PagefileOverview.csv"
""
}