Quantcast
Channel: Rob V IT
Viewing all articles
Browse latest Browse all 64

Get Cluster Shared Volume (CSV) free space with PowerShell

$
0
0

With the failover cluster manager it’s hard to summarize the free space for each CSV.
Here is a sample script to determine the free space for the Cluster Shared Volumes in each Hyper-V cluster.

Import-Module FailoverClusters

$objs = @()
$Clusters = ("CL99-HPV","CL4-HPV","CL5-HPV")

#Get CSVs foreach cluster
    foreach($Clu in $Clusters){
        $c = Get-ClusterSharedVolume -Cluster $Clu

        }

$csvs += $c

#Get CSV Info
    foreach ( $csv in $csvs )
        {
        $csvinfos = $csv | select -Property Name -ExpandProperty SharedVolumeInfo
    foreach ( $csvinfo in $csvinfos )
        {
      $obj = New-Object PSObject -Property @{
         Name        = $csv.Name
         Path        = $csvinfo.FriendlyVolumeName
         Size        = $csvinfo.Partition.Size
         FreeSpace   = $csvinfo.Partition.FreeSpace
         UsedSpace   = $csvinfo.Partition.UsedSpace
         PercentFree = $csvinfo.Partition.PercentFree
        }
      $objs += $obj
        }
    }
 

$objs |Sort-Object freespace | ft -auto Name,Path,@{ Label = "Size(GB)" ; Expression = { "{0:N2}" -f ($_.Size/1024/1024/1024) } },@{ Label = "FreeSpace(GB)" ; Expression = { "{0:N2}" -f ($_.FreeSpace/1024/1024/1024) } },@{ Label = "UsedSpace(GB)" ; Expression = { "{0:N2}" -f ($_.UsedSpace/1024/1024/1024) } },@{ Label = "PercentFree" ; Expression = { "{0:N2}" -f ($_.PercentFree) }}

 

 


Viewing all articles
Browse latest Browse all 64

Trending Articles