The memory counterpart to the CPU check: five samples five seconds apart, averaged, with an error above 85% used. Working from the total and free physical memory reported by the OS means the number matches what Task Manager shows, which saves an argument every time somebody double-checks.
powershell
function Write-Log {
param($Message)
Write-Host "<WRITE-LOG = `"*$Message*`">"
}
try {
$ramValues = @()
# Collect RAM usage 5 times, 5 seconds apart
1..5 | ForEach-Object {
$ram = Get-WmiObject Win32_OperatingSystem
$totalRam = [math]::Round($ram.TotalVisibleMemorySize / 1MB, 2)
$freeRam = [math]::Round($ram.FreePhysicalMemory / 1MB, 2)
$usedRam = $totalRam - $freeRam
$ramUsagePercent = [math]::Round(($usedRam / $totalRam) * 100, 2)
$ramValues += $ramUsagePercent
Start-Sleep -Seconds 5
}
# Calculate and output the average
$avgRam = [math]::Round(($ramValues | Measure-Object -Average).Average, 2)
Write-Log "RAM Average Usage: $avgRam %"
# Alert if average RAM exceeds 85%
if ($avgRam -gt 85) {
Write-Error "RAM usage too high: $avgRam %"
}
}
catch {
Write-Log "Unable to gather RAM Information: Device not supported."
}Run it across your fleet
This script runs as-is on a single host. Paste it into ServerEngine to schedule it, run it on a whole server group in parallel, and keep the credentials out of the file — see the scripts documentation and the credential store.
More in Checks & Diagnostics
Check Free Disk Space with PowerShell
2026-08-17Check and Restart a Windows Service with PowerShell
2026-08-17Check CPU Usage with PowerShell
2026-08-17Check Server Uptime with PowerShell
2026-08-17Check for a Pending Reboot with PowerShell
2026-08-17Check NTP Time Sync and Clock Offset with PowerShell
2026-08-17Ready when you are.
Try ServerEngine free for 7 days.