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 PowerShell MVP who has worked in IT for nearly 20 years, and currently serves as a Sr. Database Engineer in Belgium. Always an avid scripter, she attended the Monad session at Microsoft’s Professional Developers Conference in Los Angeles back in 2005 and has worked and played with PowerShell ever since. Chrissy is currently pursuing an MS in Systems Engineering at Regis University and helps maintain RealCajunRecipes.com in her spare time. She holds a number of certifications, including those relating to SQL Server, SuSE Linux, SharePoint and network security. She recently became co-lead of the SQL PASS PowerShell Virtual Chapter. You can follow her on Twitter at @cl.

Posted in PowerShell, SQL Server
One comment 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.

Leave a Reply

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

*