Cluster Shared Volume Info

$Cluster = "XXX"
$csvdata = Get-ClusterSharedVolume -cluster $Cluster
$csvs = @()
foreach ( $csvitem in ($csvdata))
{
   $cimSession = New-CimSession -ComputerName $csvitem.OwnerNode
   $DiskInfo = Get-Disk -CimSession $cimSession 
   $volumeInfo = $DiskInfo | Get-Partition | Select DiskNumber, @{Name="Volume";Expression={Get-Volume -Partition $_ | Select -ExpandProperty ObjectId}}
   $csvVolume = $csvitem.SharedVolumeInfo.Partition.Name
   $csvdisknumber = ($volumeinfo | ? { $_.Volume -eq $csvVolume}).Disknumber
   $DiskID = ($DiskInfo | where {$_.Number -eq $csvdisknumber}).UniqueId
   $csvinfo = $csvitem | select -Property Name -ExpandProperty SharedVolumeInfo
   $csv = [pscustomobject] [ordered]@{
        Name        = $csvitem.Name
        OwnerNode   = $csvitem.OwnerNode
        Path        = $csvinfo.FriendlyVolumeName
        Size        = [int]($csvinfo.Partition.Size /1GB)
        FreeSpace   = [int]($csvinfo.Partition.FreeSpace /1GB)
        UsedSpace   = [int]($csvinfo.Partition.UsedSpace /1GB)
        PercentFree = [int]$csvinfo.Partition.PercentFree
        DiskID      = $DiskId
    }
    $csvs += $csv   
}
$csvs | sort Freespace

Name : CSVxx_LUNyy
OwnerNode : HVHOST-XXX
Path : C:\ClusterStorage\Volume21
Size : 4096
FreeSpace : 1743
UsedSpace : 2353
PercentFree : 43
DiskID : 60060E801652EE00000152EE00000090

Leave a Comment