Problem overview
Unexpected disk errors can lead to data corruption, system performance degradation, and potential downtime if they go unnoticed. Manually sifting through event logs is time-consuming, and missing a single critical warning can escalate into a widespread issue for IT Professionals and MSPs managing multiple endpoints.
<#
This resource is provided as a convenience for Level users. We cannot
guarantee it will work in all environments. Please test before deploying
to your production environment. We welcome contributions to our community
library
Level Library
https://level.io/library/script-windows-monitor-check-disk-errors
#>
$ErrorActionPreference = 'silentlycontinue'
$TimeSpan = (Get-Date) - (New-TimeSpan -Day 1)
if (Get-WinEvent -FilterHashtable @{LogName = 'system'; ID = '11', '9', '15', '52', '129', '7', '98'; Level = 2, 3; ProviderName = '*disk*', '*storsvc*', '*ntfs*'; StartTime = $TimeSpan } -MaxEvents 10 | Where-Object -Property Message -Match Volume*) {
Write-Output "ALERT"
Exit 1
}
else {
Write-Output "Disks are Healthy"
Exit 0
} This PowerShell script checks the Windows System event log for common disk-related error codes. If any matching events are detected, it returns an “ALERT” message, making it easier to spot issues in real time. When no problematic events are found, it responds that disks are healthy.
You can run this script on demand by configuring a script-based monitor in Level, ensuring you’re immediately alerted whenever disk errors appear. Alternatively, you can set up a scheduled automation in Level to regularly scan event logs, helping you catch early signs of drive failures or file system inconsistencies before they impact your operations.
Use cases
- Monitoring production servers for disk or filesystem errors
- Automating proactive checks on workstation fleets
- Catching early signs of failing hard drives or storage drivers
- Preventing unplanned downtime by responding quickly to disk alerts
Recommendations
- Test the script on a single system or small environment before wide deployment
- Use a script-based monitor in Level for real-time alerts when errors appear
- Configure a schedule in Level’s Automations to run regular checks
- Investigate any “ALERT” outputs immediately to address potential disk failures
- Keep system event logs intact for accurate error tracking