PSScripts/Check-PageFile.ps1

11 lines
469 B
PowerShell
Raw Permalink Normal View History

2023-12-18 18:00:56 +00:00
# Checks if the page file is at 90% capacity
$AutoManaged = (Get-CimInstance Win32_ComputerSystem).AutomaticManagedPagefile
if ($AutoManaged -eq $false){Write-Host "Page file is not Automatically managed by Windows"; exit 0}
$page = Get-CimInstance Win32_PageFileUsage -Property *
$threshold = ($page.AllocatedBaseSize * (9/10))
if ($page.CurrentUsage -gt $threshold){"Page File Threshold reached"; exit 1}
else {"Page File Threshold NOT Reached"; exit 0}