Skip to content

Instantly share code, notes, and snippets.

@petervandivier
Last active June 6, 2022 12:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save petervandivier/6c97b60fc9a654db493931396f919698 to your computer and use it in GitHub Desktop.
Save petervandivier/6c97b60fc9a654db493931396f919698 to your computer and use it in GitHub Desktop.
Get-ClusterDiskSpacePivot

Friendly grid view of relative shared drive space and usage in a cluster.

PS C:\Users\peter.vandivier> $DriveProfiles | Format-Table

Name  01free  01total  02free  02total  03free  03total  04free  04total
----  ------  -------  ------  ------- ------- --------  ------  -------
A          0        0       0        0       0        0       0        0
C      40.04   126.51   42.09   126.51   35.49   126.51   31.51   126.51
D     460.08      512  460.08      512  460.08      512  460.08      512
E    1191.17     2048 1194.61     2048  1270.7  2047.98 1265.71  2047.98
F    1950.56  2047.98  1950.5  2047.98 1950.56  2047.98 1950.56  2047.98
G    9459.01 10199.98 9475.01 10215.98 9451.01 10191.98 9451.01 10191.98
$ComputerList = 1..4 | ForEach-Object {"node-0${_}"}
$LocalHostName = hostname
$disks = foreach($computer in $ComputerList){
if($LocalHostName -eq $computer){
Get-PSDrive -PSProvider FileSystem
}else{
Invoke-Command -ComputerName $computer{
Get-PSDrive -PSProvider FileSystem
}
}
}
$disks | Where-Object PSComputerName -eq $null | ForEach-Object {
$_ | Add-Member -Type NoteProperty -Name PSComputerName -Value $LocalHostName
}
# pivot
$DriveProfiles = $disks | Group-Object Name | Select-Object Name
foreach($drive in $DriveProfiles){
foreach($computer in $ComputerList){
$disk = $disks | Where-Object PSComputerName -eq $computer | Where-Object Name -eq $drive.Name
$FreeGb = $disk.Free / 1gb
$UsedGb = $disk.Used / 1gb
$TotalGb = $FreeGb + $UsedGb
# $Value = "$([math]::Round($FreeGb,2))gb / $([math]::Round($TotalGb,2))gb"
$abbrevName = $computer.Substring(12,2)
$NewMember = @{
Type = 'NoteProperty'
Name = "${abbrevName}free"
Value = [math]::Round($FreeGb,2)
}
$drive | Add-Member @NewMember
$NewMember = @{
Type = 'NoteProperty'
Name = "${abbrevName}total"
Value = [math]::Round($TotalGb,2)
}
$drive | Add-Member @NewMember
}
}
$DriveProfiles | Format-Table
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment