SMART (Self-Monitoring, Analysis and Reporting Technology) is a technology incorporated into most hard drives that monitors the health the drive. Using SMART, the drive will log read/write failures. If the number of failures reach a certain threshold the drive can communicate that back to the BIOS or operating system and alert the user that the drive is failing. It’s then up to the user to replace the drive before the loss of data.
I needed a way to check the SMART status of a drive remotely and was able to come up with a couple different methods to do it. I wasn’t interested in any of the metrics, only whether or not SMART thought the drive was failing. So all of the examples below will give you the same answers but I thought I’d share the code for accessing it with a couple different languages. All of the examples are remotely querying the computer using WMI, so it is important that you have security to WMI on the remote computer.
This example, from Command Prompt using WMIC, will grab the Caption and Status for all drives on the computer. Grabbing the caption is beneficial for identifying which status belongs to which drive.
Here’s an example using PowerShell:
And finally an example using VBScript:
Running any of the above should give you the Caption and Status of the drive. If the status is “Degraded” or “Pred Fail” it’s likely that the drive is going to fail and the drive needs to be replaced. There are other values that status could be set to, for a more detailed explanation see Win32_DiskDrive class on MSDN.
One thing to note is just because SMART or the Status say the drive is fine doesn’t mean it is. If the drive is having issues and the logged failures on the drive haven’t crossed a threshold the drive may still report as “OK”. However, if SMART is saying there’s a problem, you should be able to trust it.