Skip navigation
Identify Disk 1.jpg

How to Check Disk Health and Identify Unhealthy Disks in Windows Server

Leverage PowerShell to check disk health and identify disks that need to be replaced.

It’s been said that there are two types of hard disks--those that have failed and those that are going to. When a hard disk falls into an unhealthy state, it is important to replace the disk before a full-blown failure can occur. Sometimes,  however, this is easier said than done. While Windows might inform you that one of the disks attached to your server is unhealthy, it can be difficult to know for sure which physical disk to replace. Fortunately, there is an easy way to use PowerShell to check disk health and track down unhealthy disks.

If you believe that a physical disk within your system is failing, the first step in the process is to see whether Windows has identified a problem. The easiest way to do this is to open PowerShell and enter the Get-PhysicalDisk cmdlet. You can see what this looks like in Figure 1.

Identify Disk 1.jpg

Figure 1

This is what it looks like when you use the Get-PhysicalDisk cmdlet.

I created the screen capture shown above on a PC running Windows 10, but the command works in exactly the same way when used on Windows Server. The only real difference is that Windows servers often have far more disks than desktop PCs.

When using the Get-PhysicalDisk cmdlet, I recommend paying attention first to the Health Status column. As the name implies, this column indicates whether each disk is healthy. In my experience, if Windows identifies a physical disk as being unhealthy, it probably really is unhealthy. However, even if Windows indicates that a disk is healthy, that is not a guarantee of the disk’s health. (Not all that long ago, for instance, I had a disk that was clicking--a sure sign of an impending failure--but Windows continued to show the disk as being healthy.)

Incidentally, if you have a large number of disks installed in a server, you can easily filter the Get-PhysicalDisk cmdlet’s output so that only the unhealthy disks are shown. The command for doing so is:

Get-PhysicalDisk | Where-Object {$_.HealthStatus  -ne ‘Healthy’}

For the purposes of this article, let’s assume that PowerShell does identify one of the disks as being unhealthy. Since it is a physical disk that is being reported as unhealthy (as opposed to a volume health issue, which can be checked by using the Get-Volume cmdlet), it is safe to assume that the disk needs to be replaced. So, how do you figure out which physical disk to replace based on the information that Windows has given you?

One of the easiest ways to check disk health is to tell PowerShell to illuminate the disk’s LED light. Before you can do this, however, you will need to know the disk’s friendly name. If you look back at the previous screen capture, you can see that Windows provides a friendly name for each disk. This friendly name must be used in conjunction with the Enable-PhysicalDiskIdentification cmdlet.

You can easily type the Enable-PhysicalDiskIdentification cmdlet, followed by the disk’s friendly name. That technique works flawlessly. However, friendly names are often anything but friendly and can be cumbersome to type. There is also the human error factor that must be considered. If you accidentally type the wrong disk’s friendly name, you could end up replacing the wrong disk. As such, I recommend using PowerShell to extract the disk’s friendly name. You can then supply the friendly name directly to the Enable-PhysicalDiskIdentification cmdlet in the form of a variable.

The first step in the process is to create a variable named $Disk and set it equal to the unhealthy physical disk. Here is what the command looks like:

$Disk = Get-PhysicalDisk | Where-Object {$_.HealthStatus  -ne ‘Healthy’}

Next, I recommend creating a second variable. We’ll call this one $Name. We will set it equal to the disk’s friendly name. Here is the command for doing so:

$Name = $Disk.FriendlyName

You can see how these commands work in Figure 2. I don’t have an unhealthy disk on my system, so I made a slight modification to the first command so that it would retrieve a disk based on its number rather than on its health status.

Identify Disk 2.jpg

Figure 2

I have written the disk’s friendly name to a variable named $Name.

The last step in the process is to enter the Enable-PhysicalDiskIdentification cmdlet, followed by the $Name variable. Here is what the command looks like:

Enable-PhysicalDiskIdentification $Name

If you receive an error while performing this operation, check to make sure that you are working within an elevated PowerShell session. It is also important to note that this command works only if each disk has a dedicated LED and the hardware supports disk identification. Otherwise, you will receive a Not Supported error.

When you have finished identifying the disk, you can use the following command to turn the disk’s LED back off:

Disable-PhysicalDiskIdentification $Name
TAGS: PowerShell
Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish