Last week, I was looking for a way to retrieve the Clustered Shared Volume (CSV) to physical disk mapping on Windows Server 2012 using PowerShell. I have seen some scripts elsewhere that use DiskSignature to get this mapping using WMI. However, I wasn’t able to follow the same approach as the disk signature for some of the volumes I am using turned out to be 0x0 for some reason.
So, I started looking at an alternate approach and figured that I could use the volume path as the key. So, I started wrapping that code in a function and this is what I ended up with.
Function Get-CSVtoPhysicalDiskMapping {
param (
[string]$clustername = "."
)
$clusterSharedVolume = Get-ClusterSharedVolume -Cluster $clusterName
foreach ($volume in $clusterSharedVolume) {
$volumeowner = $volume.OwnerNode.Name
$csvVolume = $volume.SharedVolumeInfo.Partition.Name
$cimSession = New-CimSession -ComputerName $volumeowner
$volumeInfo = Get-Disk -CimSession $cimSession | Get-Partition | Select DiskNumber, @{Name="Volume";Expression={Get-Volume -Partition $_ | Select -ExpandProperty ObjectId}}
$csvdisknumber = ($volumeinfo | ? { $_.Volume -eq $csvVolume}).Disknumber
$csvtophysicaldisk = New-Object -TypeName PSObject -Property @{
"CSVName" = $volume.Name
"CSVVolumePath" = $volume.SharedVolumeInfo.FriendlyVolumeName
"CSVOwnerNode"= $volumeowner
"CSVPhysicalDiskNumber" = $csvdisknumber
"CSVPartitionNumber" = $volume.SharedVolumeInfo.PartitionNumber
}
$csvtophysicaldisk
}
}
The code is self-explanatory. Since I am using the Windows Server 2012 storage cmdlets, this will work only on Windows Server 2012 systems and that is all I tested also.
Here is how you can use this function
Get-CSVtoPhysicalDiskMapping | ft -AutoSize Get-CSVtoPhysicalDiskMapping -ClusterName MyCluster01 | ft -AutoSize
And, this is what you will see.
Hope this is helpful.

