PowerShell for Failover Clustering: Finding the Drive Letter

PowerShell for Failover Clustering: Finding the Drive Letter

Rate This
  • Comments 6

Hi cluster scripting fans,


I often find myself looking for the drive letter(s) for a physical disk resource in a PowerShell console/script.  After a bit of investigation, here is a way to do that using Cluster WMI through PowerShell:


$DiskResourceName = "Cluster Disk 2"

$DiskResource = gwmi MSCluster_Resource -Namespace root/mscluster | ?{ $_.Name -eq $DiskResourceName }

$Disk = gwmi -Namespace root/mscluster -Query "Associators of {$DiskResource} Where ResultClass=MSCluster_Disk"

$Partition = gwmi -Namespace root/mscluster -Query "Associators of {$Disk} Where ResultClass=MSCluster_DiskPartition"


After you run those CMDlets in your PowerShell window on a cluster node, the $Partition variable will contain a MSCluster_DiskPartition WMI object per volume on the physical disk resource you specified with $DiskResourceName.


Here is an example when I run this against a physical disk resource with one partition:


$Partition | select Path





… and here with two partitions:

PS G:\Windows\system32> $Partition | select Path







Ahmed Bisht

Senior Program Manager

Clustering & High-Availability


Leave a Comment
  • Please add 8 and 1 and type the answer here:
  • Post
  • Works well for my Win 2008 Failover Clustering Environment. Any suggestions how to do that with MSCS 2003 ? Some WMI Classes used here don´t exist in Microosoft Cluster 2003

  • Hi Klaus,

    You are correct - although PowerShell will often work down-level at least one version, unfortunately the WMI Disk class that this PowerShell script was introduced in Windows 2008.


  • would be very nice to have an example how to change or set a drive letter in Windows Server 2008 R2 (or later) using powershell only.

  • it works perfect. u r awesome

  • I would like to +1 the request for an example of how to change or set a drive letter .

  • Thanks alot for this script example !!! I needed it because physical disk name can change from the  partition name and then i can't find the drive letter to create folders on.

    Have been looking for this for a while but my wmi query didn't get that far ..


Page 1 of 1 (6 items)