Skip to content

How to keep drive healthy with PDQ Inventory & PowerShell Scanners

Brock Bingham candid headshot
Brock Bingham|Updated June 10, 2021
drive health
drive health

I love to see how technology evolves over time. For example, cars went from nothing more than a motor, a seat, and a steering mechanism, to world-class sound systems, massaging seats, and fully autonomous self-driving (well, almost). 

As new technologies emerge, it's difficult to see how they will shape and evolve over time. One thing's for sure, though, I don't think anyone predicted computers would eventually develop from this data input and manipulation box:

Drives1

To this meme generating, 4K 60fps eye-watering, noob crushing, crypto mining, trance-inducing powerhouse:

Drives2

Now, excuse me while I put on my sunglasses for the remainder of this article.

Same, but Different, but Still the Same

While these two machines may look drastically different, it's like my mom always said: it's what's on the inside that counts. Sure, the IMB PC XT didn't have all the RGB, which is obviously where most of the performance comes from. However, it had a processor,  128KB of RAM,  and a motherboard--and it was the first personal computer to come with a built-in hard drive. 

Fast forward to today, and once you put on your sunglasses to see past the RGB, you'll see that computers today are still rocking these components. However, the speeds, capacities, and heat generated by these components have vastly increased, which is why we need to keep a watchful eye on our components to ensure they continue to operate at peak performance.

With Great Power Comes Great Responsibility

If you read my recent blog, What Is The PowerShell Equivalent Of Chkdsk, you'll know that, in my opinion, the hard drive (HDD or SDD) is the most critical component in computers. My reasoning is simple. The hard drive is responsible for storing our precious data. If you've ever had a hard drive fail, you know what true despair feels like.

Drives3

While drives have progressed leaps and bounds in recent years, they are still a bit on the fragile side. For example, I once had an external hard drive that I set down a little too harshly while it was running…it died.  I wasn't being careless or anything, but it's not like I was setting down a newborn for a nap.  I just set it down, and the next thing I heard was a subtle, steady clicking sound, indicating my drive had just given up the ghost.

Solid-state drives, which have been one of the most significant computer advancements in the last 15 years, resolve some of the fragility issues of hard disk drives because they don't have any moving parts. However, SSD's have their own disadvantages that users need to be aware of. For one, data recovery can be much more difficult if your SSD fails versus a traditional HDD. Another shortcoming is that SSD's have a limited life span.  Cells on an SSD have a limited number of writes they can perform before they become unusable.

So, what can you do to ensure your drives are in good condition, especially when you may have hundreds or thousands of computers you manage?

Monitoring Your Precious Data With PowerShell

While you can never predict 100% of drive failures, it is possible to predict a good majority of them. Using PowerShell, we can collect a lot of valuable diagnostic data from our drives, which will help us know if one will soon be kicking the bucket. Here are the PowerShell commands we'll be focusing on.

Get-PhysicalDisk
Get-PhysicalDisk | Get-StorageReliabilityCounter

The first command, Get-PhysicalDisk, is excellent at returning identification data about the drives installed in your computer.

The second command, Get-StorageReliabilityCounter, will return a wealth of information about the health of the drives when added to the first command.

Here's an example of some of the useful data that can be returned with Get-PhysicalDisk.

Drives4

And here's an example of some of the helpful data that can be returned with Get-PhysicalDisk | Get-StorageReliabilityCounter.

Drives5

As you can see, we're able to return some excellent identification and drive condition data. Unfortunately, since these are two separate commands, we'll need to use some PowerShell wizardry to combine the returned information. Luckily, PDQ.com is full of PowerShell wizards. Thanks to Andrew Pla, who you may have seen in our recent webcasts, for throwing this one together.

$disks = get-physicaldisk foreach($disk in $disks){ $storageCounter = $disk | Get-StorageReliabilityCounter [pscustomobject]@{FriendlyName = $disk.FriendlyName MediaType = $disk.MediaType HealthStatus = $disk.HealthStatus OperationalStatus = $disk.OperationalStatus Wear = $storageCounter.Wear ReadErrorsTotal = $storageCounter.ReadErrorsTotal Temperature = $storageCounter.Temperature TemperatureMax = $storageCounter.TemperatureMax}}
Drives6

Look at all that sweet data. While this is super helpful stuff, nobody wants to run this command manually, especially if you manage hundreds or thousands of computers, so it's time to bring in the big guns.

Creating a PowerShell Scanner in PDQ Inventory

Now that we've got our PowerShell dialed in, it's time to create a PowerShell scanner in PDQ Inventory. PowerShell scanners are great because they can be configured to run on a schedule, and all the data it returns will be stored in PDQ Inventory for us to view whenever we need it.

Since I want this data collected regularly, we'll create a new scanner and attach it to the existing Standard scan profile.

1. In PDQ Inventory, click Scan Profiles

Drives7

2. Double-click the Standard scan profile

Drives8

3. Click Add > PowerShell

Drives9

4. Give the new scanner a descriptive name

5. Either save the script to your repository in a ps1 file or paste the script into the Script field

Drives10

6. Click OK twice to save and close the open windows.

That's all there is to it!  So, now you can go ahead and run the standard scan profile against your computers to return all that helpful drive data. Once the scan finishes, double-click on any computer in Inventory and then click on the PowerShell menu option.

Drives11

Finally, ensure you have the correct PowerShell scanner selected to view the results.

Drives12

Here are the results:

Drives13

Reducing Your Risk Moving Forward

While this data won't stop us from ever experiencing a drive failure again, it will reduce unexpected failures significantly. So, make sure to review this information periodically to catch drives that are looking to bite the bullet soon. And, as a good rule of thumb, make sure your data is backed up.

Brock Bingham candid headshot
Brock Bingham

Born in the '80s and raised by his NES, Brock quickly fell in love with everything tech. With over 15 years of IT experience, Brock now enjoys the life of luxury as a renowned tech blogger and receiver of many Dundie Awards. In his free time, Brock enjoys adventuring with his wife, kids, and dogs, while dreaming of retirement.

Related articles