Functions/Get-HyperVRamCommit.ps1
function Get-HyperVRamCommit { [CmdletBinding()] param ( # [Parameter(Mandatory)] [string] $Driveletter ) $Result = [PSCustomObject]@{ Total_HostRAM = (Get-CimInstance Win32_PhysicalMemory | Measure-Object -Sum -Property Capacity | Select-Object -ExpandProperty Sum) / 1024 / 1024 / 1024 Total_vRAM = (Get-VM | Measure-Object -Sum -Property MemoryStartup | Select-Object -ExpandProperty Sum) / 1024 / 1024 / 1024 Active_vRAM = (Get-VM | Measure-Object -Sum -Property MemoryAssigned | Select-Object -ExpandProperty Sum) / 1024 / 1024 / 1024 } if ($Result.Active_vRAM -ge $Result.Total_HostRAM) { Write-Host "RAM overcommitted!" -ForegroundColor Red } else { Write-Host "RAM not overcommitted" -ForegroundColor Green } return $Result } |