PowerShell Script: Check Drive Health with Drive Letter

Abstract: Correlate physical disk health status with Windows drive letters using PowerShell Storage module cmdlets.

Created: 2026-10-20 by

You can check drive health and map it to a drive letter by using the Get-PhysicalDisk cmdlet from the Storage module combined with Get-Volume. This approach allows you to correlate the unique identifier of a physical disk with its assigned Windows drive letter, enabling precise monitoring of hardware status for specific mounted volumes.

Understanding the Core Cmdlets

To effectively monitor storage health in Windows PowerShell, you must understand how the operating system abstracts physical hardware. The Storage module provides the primary interface for this interaction. The most critical command is Get-PhysicalDisk, which retrieves detailed information about all physical disks attached to the system. This includes properties such as HealthStatus, which indicates whether the drive is healthy, warning, or unknown, and OperationalStatus, which shows if the drive is online or offline. However, Get-PhysicalDisk does not natively display drive letters. Drive letters are managed at the volume level, not the disk level. Therefore, you need to use Get-Volume to retrieve information about mounted volumes, including their drive letters and file systems. The challenge lies in linking these two distinct entities: the physical disk and the logical volume sitting on top of it.

The Linking Mechanism

The connection between a physical disk and a volume is established through the DiskNumber property. Every physical disk has a unique integer identifier known as the disk number. Similarly, every volume has a DiskNumber property that references the physical disk on which it resides. By matching the DiskNumber from both cmdlets, you can create a comprehensive view of your storage infrastructure. This method works reliably across various Windows versions that support the Storage module, including Windows Server 2012 R2 and later, as well as modern versions of Windows 10 and 11. It is important to note that this technique applies primarily to basic, simple, and dynamic volumes. Complex configurations like RAID arrays or software-defined storage might require additional handling depending on the specific implementation.

Constructing the Health Check Script

Building a script to report drive health involves several steps: retrieving the physical disks, iterating through them, finding associated volumes, and formatting the output. Below is a robust example that demonstrates this process.
$disks = Get-PhysicalDisk
$results = @()

foreach ($disk in $disks) {
    # Skip virtual disks or those without a clear operational status
    if ($disk.OperationalStatus -ne 'Online') {
        continue
    }

    # Find volumes associated with this disk number
    $volumes = Get-Volume | Where-Object { $_.DiskNumber -eq $disk.DiskNumber }

    foreach ($volume in $volumes) {
        # Create a custom object for clean output
        $result = [PSCustomObject]@{
            DiskName   = $disk.FriendlyName
            DiskNumber = $disk.DiskNumber
            DriveLetter = if ($volume.DriveLetter) { $volume.DriveLetter + ":" } else { "N/A" }
            HealthStatus = $disk.HealthStatus
            OperationalStatus = $disk.OperationalStatus
            SizeGB     = [math]::Round($volume.Size / 1GB, 2)
        }
        $results += $result
    }
}

# Display the results in a table format
$results | Format-Table -AutoSize
This script first captures all physical disks into an array. It then loops through each disk, checking if it is online. If the disk is online, it queries for all volumes that share the same DiskNumber. For each volume found, it constructs a custom PowerShell object containing the relevant health metrics and drive letter. Finally, it formats these objects into a readable table.

Interpreting Health Statuses

When running this script, you will encounter various values in the HealthStatus column. Understanding these values is crucial for proactive maintenance. The most common statuses include:
  • Healthy: The drive is functioning normally with no detected errors. SMART data indicates no imminent failure.
  • Warning: The drive has detected issues that may lead to failure. This could be due to bad sectors, high temperature, or other SMART attributes exceeding thresholds. Immediate backup and replacement planning are recommended.
  • Unknown: The system cannot determine the health status. This often occurs with older drives, certain USB enclosures, or when SMART data is inaccessible. Manual inspection or third-party tools may be required.
  • Critical: The drive has failed or is in a state where data integrity is severely compromised. Data loss may have already occurred.
It is also important to distinguish between HealthStatus and OperationalStatus. A drive might be marked as Healthy but have an OperationalStatus of Offline due to manual dismounting or power management settings. Always check both fields for a complete picture.

Advanced Filtering and Alerting

For production environments, you likely want to filter out healthy drives and focus only on those requiring attention. You can modify the script to output only warnings or failures. Additionally, integrating this script with notification systems allows for automated alerts. If you need to negate specific options during filtering, such as excluding removable drives, you can use standard PowerShell comparison operators. For more complex logic involving negation of multiple conditions, refer to guides on negating options in PowerShell to ensure your filters are precise and efficient. You can also extend this script to log results over time. By appending the output to a CSV file or a database, you can track health trends. A gradual increase in warning flags can predict hardware failure before it becomes critical. This historical data is invaluable for capacity planning and procurement cycles.

Limitations and Considerations

While this method is effective for most local storage, it has limitations. It does not work for network-mounted drives (like SMB shares) because they do not have a direct DiskNumber association in the local storage stack. Furthermore, some virtual machines or cloud-based instances may not expose physical disk details directly to the guest OS, requiring host-level monitoring instead. Additionally, access rights matter. Running this script typically requires administrative privileges, especially when querying detailed SMART data or accessing certain storage subsystems. Ensure your execution policy allows for script execution and that the user account has sufficient permissions. For scenarios where you need to automate file movements based on drive health, consider combining this health check with file management scripts. Resources on moving files with PowerShell can help you automate cleanup or migration tasks when a drive reaches a critical state.

Frequently Asked Questions

Why does my drive show N/A for the drive letter?

This occurs when the physical disk has no mounted volume assigned to it, or the volume exists but lacks a drive letter assignment. Some partitions, such as recovery partitions or EFI system partitions, often do not have drive letters. To resolve this, check if the volume is mounted and assign a letter if necessary using the Disk Management tool or PowerShell's Set-Volume cmdlet.

Can I use this script on Windows Server?

Yes, the Storage module is available on Windows Server 2012 R2 and later versions. Ensure that the Storage Services role is installed if you are dealing with advanced storage features like Storage Spaces. The core cmdlets Get-PhysicalDisk and Get-Volume function identically across client and server editions for basic health checks.

How do I handle multiple volumes on a single disk?

The script iterates through all volumes associated with a given DiskNumber. If a disk has multiple partitions, such as a C: drive and a D: drive, the loop will create separate entries for each volume. Each entry will retain the same DiskName and HealthStatus, allowing you to see that both volumes share the same underlying physical health.

What if Get-PhysicalDisk returns no results?

This usually indicates that the Storage module is not loaded or the cmdlet is unavailable. Try importing the module explicitly with Import-Module Storage. If it still fails, ensure you are running PowerShell version 3.0 or higher, as earlier versions do not support these cmdlets. Also, verify that you have administrative privileges.

Is there a risk of data loss when running this script?

No, reading health status and volume information is a non-destructive operation. The script only queries metadata and does not modify any disk structures or files. However, always ensure you have backups before making any changes to storage configurations, even if the diagnostic script itself is safe.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More