Skip navigation
Disk Latency 2.jpg

How to Use PowerShell to Track Storage Consumption Trends

Knowing how to use PowerShell for tracking will help admins ensure balanced storage capacity.

For more technical explainers on PowerShell, read our updated PowerShell 101: A Technical Explainer for IT Pros report.

Probably the single most important thing that a storage administrator needs to track is how quickly storage is being consumed. If a storage administrator underestimates the rate of storage consumption, the organization could be left with inadequate capacity. Conversely, if a storage administrator overestimates the rate of storage consumption, the organization may end up wasting money by purchasing more storage than it actually needs. There are countless third-party tools that can help storage admins accurately project the rate of storage consumption, but what many people don’t realize is that Windows PowerShell has storage consumption tracking capabilities built in. Here’s how to use PowerShell to track storage consumption trends.

Storage consumption tracking works differently depending on whether you are monitoring a standard storage volume or a cluster shared volume. For the purposes of this article on how to use PowerShell for tracking storage consumption, I will focus on cluster shared volumes.

The first step in knowing how to use PowerShell to track the rate of storage consumption is to map a cluster shared volume to a variable. There are many ways to do this, but the easiest is to use either the volume’s friendly name or its file system type. Newer Cluster Shared Volumes generally have a file system type of CSVFS_ReFS, so I am going to use that as the basis for the mapping. Obviously, if you are using a different file system, then you will want to map the variable based on the file system that you are using, or use a different qualifier such as the volume’s friendly name.

Here is a command that you can use:

$CSV = Get-Volume | Where-Object FileSystemType -eq “CSVFS_ReFS”

This command creates a variable called $CSV and maps it to all of the system’s connected Cluster Shared Volumes. You can verify the variable mapping by entering the name of the variable ($CSV in this case). You can see what this looks like in Figure 1.

PowerShell Storage Tracking 1.jpg

Figure 1

I have mapped the $CSV variable to my cluster shared volume.

Now that we have mapped a variable to the cluster shared volume, the next thing that we need to do is to use that variable to retrieve the volume’s storage consumption history. This is actually easier to do than you might expect. PowerShell includes a cmdlet called Get-ClusterPerf that can be used to retrieve a wide variety of performance statistics for a cluster node.

If you take a look at Figure 2, you can see where I ran this cmdlet directly on a cluster node without any additional input. The cmdlet returned an impressive amount of information. For example, you can see the memory and CPU resources that the cluster node is using. From a storage standpoint, you can view things like the volume’s IOPS, latency and throughput.

PowerShell Storage Tracking 2.jpg

Figure 2

The Get-ClusterPerf command returns a significant amount of information pertaining to the cluster’s resource usage.

As you look at the information shown in the previous figure, you will notice that one of the series that is included among the results is Volume.Size.Available. As you would expect, this value tells you how much space is remaining on the volume.

The question is, how you can use this value to track storage consumption over time?

The trick to making this work lies in the fact that the Get-ClusterPerf cmdlet captures a datapoint each day, and can retain up to a year’s worth of data. This means that it is possible to look back on how the available storage has changed from one day to the next over an extended period of time.

To do so, all you have to do is pipe the $CSV variable’s contents into the Get-ClusterPerf cmdlet and tell PowerShell which series you want to use, as well as how much data you wish to include in the results. Suppose, for example, you named your variable $CSV, just as I did, and you want to see the Volume.Size.Available data for the last year. To do so, you would use this command:

$CSV | Get-ClusterPerf -VolumeSeriesName “Volume.Size.Available” -TimeFrame “last year”

You can see what this looks like in Figure 3. In this case, only about a week’s worth of data has been returned because the Cluster Shared Volume was only recently created. It’s also worth noting that the amount of available space hasn’t changed during that time because I am using a lab setup without any data. Even so, you can see how this technique could help you to track storage consumption over time.

If you would rather not manually parse the raw data to make storage consumption projections, there are a couple of things that you can do. One option is to write the data to a CSV file, import it into Excel, and then make a chart based on the data.

Another option is to use Microsoft’s Show-StorageTrend script. This script is based on a technique that is similar to the one that I just explained, but it extrapolates the amount of space being consumed each day and projects how many days remain until the volume is full.

Tracking storage consumption is an essential job for storage administrators, which makes it essential to know how to use PowerShell to perform the task.

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.