Skip to content

Instantly share code, notes, and snippets.

@mattmcnabb
Last active December 2, 2017 02:23
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 mattmcnabb/d0b97325db21fbd1979283b23b12a1a8 to your computer and use it in GitHub Desktop.
Save mattmcnabb/d0b97325db21fbd1979283b23b12a1a8 to your computer and use it in GitHub Desktop.
Create a disk space doughnut chart
$disks = Get-WmiObject -ClassName Win32_LogicalDisk
ForEach ($disk in $disks) {
$FreeSpace = [Math]::Round($disk.FreeSpace / 1GB, 2)
$UsedSpace = [Math]::Round(($Disk.Size - $disk.FreeSpace) / 1GB, 2)
New-UDColumn -Content {
New-UdChart -Title $Disk.DeviceId -Type Doughnut -Endpoint {
[PSCustomObject]@{Space = $UsedSpace; Name = "UsedSpace"},
[PSCustomObject]@{Space = $FreeSpace; Name = "FreeSpace"} |
Out-UDChartData -DataProperty "Space" -LabelProperty "Name"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment