Physical drive health (Windows) powershell
Reports SMART-derived health status for every physical disk (Healthy / Warning / Unhealthy). Catches failing disks before they take the array down.
Placeholders only. Before running, replace
YOUR_URL with your capture endpoint's POST URL
.
(Open this page from your capture object to have these auto-filled.)
# drive-health.ps1 — physical disk health status.
$Url = "YOUR_URL/drive-health"
$Disks = Get-PhysicalDisk | Select-Object FriendlyName, MediaType, HealthStatus, OperationalStatus
$Statuses = @{}
$AnyUnhealthy = $false
foreach ($d in $Disks) {
$Statuses[$d.FriendlyName] = @{
media = "$($d.MediaType)"
health = "$($d.HealthStatus)"
operational = "$($d.OperationalStatus)"
}
if ($d.HealthStatus -ne 'Healthy') { $AnyUnhealthy = $true }
}
$Body = (@{
hostname = $env:COMPUTERNAME
disks = $Statuses
any_unhealthy = $AnyUnhealthy
}) | ConvertTo-Json -Compress -Depth 5
Invoke-RestMethod -Uri $Url -Method Post -Body $Body `
-ContentType "application/json" -TimeoutSec 15 | Out-Null
Recommended pairing
Add a capture.value check to this capture object.
json_path = any_unhealthy, op = ==, threshold = true (severity: crit).
What is the filename?
drive-health.ps1 — this is the suggested name for the downloaded file. Rename freely if you prefer.
site1.erralert.com