PLEASE READ FIRST!

I've now been blogging here since 2007! ...Wow, has it been that long already?! Over the years, I've covered a wide array of subjects from scripting, troubleshooting, to the occasional hobby project. I have literally heard from thousands of you over the years with questions or even just offering me a bit of thanks!

Recently, I quit my full-time job and started work on an IT business, Rhythm IT Solutions, helping other IT departments manage their IT environments. We're offering consulting & professional services (Office 365 Migrations, Network Discovery, Firewall Management, etc...) as well as Endpoint Management (AV, Patch Management EDR, Managed Backup, etc...)



If there is something (on my blog or not) that you could use some additional help with, I would LOVE to hear from you! Please feel free to reach out to me using the contact links here or the contact form on Rhythm's website.

For those wondering, I do plan on continuing my work on the blog. So don't worry! There are plenty of Greg Strike posts yet to come! 😊 Thanks for stopping by!

PLEASE READ FIRST!




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.

WMIC /Node:REMOTECOMPUTER DiskDrive GET Caption, Status

Here’s an example using PowerShell:

$WMI = Get-WMIObject -Computer REMOTECOMPUTER -Class Win32_DiskDrive
ForEach ($Drive in $WMI){
     $Drive.Caption + ": " + $Drive.Status
}

And finally an example using VBScript:

strComputer = "REMOTECOMPUTER"
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colDrives = objWMIService.ExecQuery("Select * from Win32_DiskDrive")

For Each Drive in colDrives
    WScript.Echo Drive.Caption & ": " & Drive.Status
Next

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.



PLEASE READ FIRST!

I've now been blogging here since 2007! ...Wow, has it been that long already?! Over the years, I've covered a wide array of subjects from scripting, troubleshooting, to the occasional hobby project. I have literally heard from thousands of you over the years with questions or even just offering me a bit of thanks!

Recently, I quit my full-time job and started work on an IT business, Rhythm IT Solutions, helping other IT departments manage their IT environments. We're offering consulting & professional services (Office 365 Migrations, Network Discovery, Firewall Management, etc...) as well as Endpoint Management (AV, Patch Management EDR, Managed Backup, etc...)



If there is something (on my blog or not) that you could use some additional help with, I would LOVE to hear from you! Please feel free to reach out to me using the contact links here or the contact form on Rhythm's website.

For those wondering, I do plan on continuing my work on the blog. So don't worry! There are plenty of Greg Strike posts yet to come! 😊 Thanks for stopping by!

PLEASE READ FIRST!





Gregory Strike

Husband, father, IT dude & blogger wrapped up into one good looking package.