Level Verified

Windows Monitor - Check SMART Disk Script

Checks Windows disks for early signs of failure using SMART data. Triggers an alert if any disk health status is not “Healthy,” allowing timely repairs or replacements to avoid data loss and downtime.

Import into Level

Problem overview

Hard drive failures can lead to data corruption, downtime, and costly disruptions. Many IT professionals struggle to predict disk failures before they happen, lacking insight into critical hardware health metrics. By automatically monitoring SMART data, this script helps ensure potential disk issues are quickly spotted and addressed.

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-smart-disk
#>

# Checks local disks for health status
$DiskState = Get-PhysicalDisk | Where-Object {$_.HealthStatus  -ne 'Healthy'}
if ($DiskState){
    $DiskState | out-host
    write-host "ALERT: Disk failure predicted!"
	exit 1
}

This script queries each physical disk on a Windows system via PowerShell’s Get-PhysicalDisk command. It then checks for any disks with a health status that isn’t Healthy, raising an alert and exiting with a nonzero status if issues are detected. This enables quick detection of early warning signs, allowing you to configure or run follow-up automations in Level to attempt repairs or schedule part replacements before failures occur.

Use cases

  • Preventing unexpected hardware failures by actively monitoring disk health
  • Adding an extra layer of protection for critical data storage on workstation or server environments
  • Integrating with Level’s alerting to expedite response times
  • Triggering an automated repair sequence or replacement procedures

Recommendations

  • Configure a script-based monitor in Level to run this script a set frequency, checking disk health regularly
  • For larger environments, consider frequent interval checks on critical servers, while scheduling routine checks for workstations
  • Test in a non-production environment to confirm that the script works with your specific disk configurations
  • If a disk is flagged, follow up with hardware diagnostics tools and consider running a repair automation (e.g., CHKDSK) through Level
  • Ensure backup routines are current to mitigate data loss risks

Frequently asked questions.

Does this script attempt any repairs on its own?

No, it strictly checks disk health status and exits with an alert if issues are found. Use a separate repair script or automation if you want to attempt repairs.

What versions of Windows are supported?

It relies on Get-PhysicalDisk, which is available on Windows 8.1/Server 2012 and later. Test compatibility in your environment.

Can I use this script to monitor external USB drives?

Yes, if they appear under Get-PhysicalDisk. However, some external drives may have limited SMART reporting.

What happens if no disks are flagged as unhealthy?

The script exits with a success code (0), indicating no immediate hardware concerns.

Is it safe to run this script on production servers?

Reading SMART data is non-intrusive, but always test thoroughly to ensure compatibility with your specific environment.

Ready when you are.

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