Script to check Disk Usage (Not Space)

I’m looking for a way to check the disk usage. After windows updates some computers are at 100% and the computers are crawling. Disk I/O Usage.

It can be done - you’d probably want to create a tool consisting of a PowerShell script using performance counters and return a particular value. You can then create an alert based on the return value when the tool is run.

Get-Counter is incredibly flexible and it wouldn’t take much to write something that would create a fail condition based on your criteria.

For example, this line:

Get-Counter -Counter "\PhysicalDisk(_Total)\% Disk Time" -SampleInterval 2 -MaxSamples 10 | Foreach-Object {$_.CounterSamples[0].CookedValue}

Will give you the percentage of time the disk was active 10 times every two seconds. You can then work out an average or median value and if it’s above the threshold generate a failure.

It may be something like Disk Queue Length would be a better metric to monitor rather than activity time, but I guess it just depends on what you’re dealing with.