Level Verified

Windows Monitor - Check Disk Errors Script

Scans Windows event logs for common disk-related errors and alerts if issues are found. Ideal for script-based monitoring in Level to proactively address hardware or file system problems.

Import into Level

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.

PowerShell 100s timeout Runs as Local system Windows
<#
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

Frequently asked questions.

How do I run this script?

Simply import it into Level, then add it to a script-based monitor or an Automation workflow.

Which event IDs does the script check?

It looks for critical disk-related events (IDs 11, 9, 15, 52, 129, 7, 98) in the System log.

Will it fix the disk errors automatically?

No, the script only detects potential issues. Pair it with a remediation plan or automation to handle errors.

What if multiple disks are connected to the system?

The script checks all relevant events in the Windows System log, covering all disk devices on the machine.

How often should I run it?

Frequency depends on your environment. Critical servers may benefit from hourly checks, while less critical systems might be fine with daily scans.

Ready when you are.

No credit card. No sales call. Just sign up and start managing.