PowerShell v3: Get Volume Information for Clustered SQL Server Storage

Unfortunately, there are no native PowerShell Failover Cluster cmdlets which will give you the volume information for disks in a cluster. I’ve seen some bloggers use Get-ClusterSharedVolume but a Cluster Shared Volume or CSV is different from volumes used within a SQL cluster.

The script below, which was written with the help of this post on StackOverflow, gets the volume information for disks within specific SQL Server instances on all the clusters in a domain. This does not work with Availability Groups since they don’t use shared storage.

I am writing this code for another project which stores the values in a database, which is why I’m using variables and Write-Host in the example. The output will look like this (well, hopefully yours will have a more advanced storage structure. These particular clustered instances were created for proof-of-concept):

PS C:\Users\administrator> .\Get-ClusteredDiskInfo.ps1
Cluster: CLUSTER2
SQL Resource: SQL Server
Cluster disk: Cluster Disk 1
Disk state: Online
Disk Drive: Y:
Disk Label: iscsivol
Disk Size: 102269
Disk Free: 102111

Cluster: CLUSTER2
SQL Resource: SQL Server (SQL2)
Cluster disk: Cluster Disk 3
Disk state: Online
Disk Drive: F:
Disk Label: iscsivol2
Disk Size: 20476
Disk Free: 20358

Chrissy is a Cloud and Datacenter Management MVP who has worked in IT for over 20 years. She is the creator of the popular SQL PowerShell module dbatools, and holds a number of certifications, including those relating to SQL Server, Linux, SharePoint and network security. You can follow her on Twitter at @cl.

Posted in PowerShell, SQL Server
3 comments on “PowerShell v3: Get Volume Information for Clustered SQL Server Storage
  1. James Lupolt says:

    Thanks for this — I didn’t know about the GetRelated() method, which makes for much less ugly code compared to using “ASSOCIATORS OF …” in WQL.

  2. Rafael says:

    Very nice script! Thank You very much.

    I’am Using Your script as a base for an Icinga Monitoring Check. If it’s okay for You, i would like to upload my check Script to Github.

    Best Regards,
    Rafael

Leave a Reply

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

*