Disk Space Usage Trend Analysis – Part 1


Traditionally, alerting on disk space usage at say 90% or 95% has been the way to “proactively” resolve disk space issues before they become critical.  Of course these arbitrary figures don’t often fit the mould and our proactive alerts make us more reactive than anything else; scrambling to delete/compress/archive files and as a last resort expanding virtual disks.

Then what happens if there is no more space available on the SAN and you’re waiting weeks (or months) for new hardware? Inevitably someone will ask “why didn’t you know ahead of time this was going to happen?”

This is Part 1 on how to develop a sophisticated report for predicting (as best as possible) when your servers hard disks are going to run out of space, and hopefully gain better insight into disk growth, and reach the ultimate goal of capacity management.

After this is complete, you will be able to confidently answers questions like:

  • What is the rate of change for each servers hard disks? How much are they growing by each day?
  • At its current growth rate, in how many days will the disk run out of space?

The broad strokes of this solution are:

  • Collect disk space usage, once per day, for all servers over a period of time. (Part 1)
  • Using the data collected, develop a trend line. (Part 2)
  • Create graphs of the usage and usage trend. (Part 3)

So at the end of Part 3, you should end up with something that looks like this:


To begin, the below script should be run as a scheduled task (at the same time every day) and will collect disk usage across all servers in your domain.  Here’s how to create a Schedule Task to run a PowerShell script.


After the above script runs, you’ll end up with files like those below in c:\scripts\disklog (one for each server/drive combination):


After several days of this script being run, each csv/txt file will look like the below (each line has the date and the disk space used in GB):



In Part 2, we will look at creating a second script to take the data collected and calculate a trend line to determine the average rate of change and try and predict when the disk will run out of space.


5 Comments Disk Space Usage Trend Analysis – Part 1

    1. Ryan Yeager

      Strange…I’ve run this several times, I click start and it says its finished each time, I have broken it out per part of script as well…

      First error, it said that hostname was null…I am going to continue to tweak and let you know

  1. PJ

    Hi , just one issue , should there be any wmi issues on a server the rest of the script does not complete or update , the command goes in a hung state.
    Is there anyway to omit these servers until the issue on the server is resolved. eg some sort of timeout value

    1. Kamal

      You could add a port check with:

      $openport = (test-netconnection -port 445 $hostname).tcptestsucceeded;


Leave a Reply

Your email address will not be published. Required fields are marked *