Back to Resources
Level
Script
General
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 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.
1<#
2This resource is provided as a convenience for Level users. We cannot
3guarantee it will work in all environments. Please test before deploying
4to your production environment. We welcome contributions to our community
5library
6
7Level Library
8https://level.io/library/script-windows-monitor-check-disk-errors
9#>
10
11$ErrorActionPreference = 'silentlycontinue'
12$TimeSpan = (Get-Date) - (New-TimeSpan -Day 1)
13if (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*) {
14 Write-Output "ALERT"
15 Exit 1
16}
17else {
18 Write-Output "Disks are Healthy"
19 Exit 0
20}
Windows Monitor - Check Disk Errors
This script checks the Windows System event logs for critical or warning events related to disk or storage issues from the past 24 hours. It filters events by specific IDs and providers and outputs "ALERT" with an error exit code if issues are found, or "Disks are Healthy" with a success exit code if no problems are detected.
PowerShell
100
Local system
Explore more automations, scripts, and policies to further enhance your IT operations.