Chapters/graphical-controllers-wpf/DiskStats.ps1

#disk stat code

#start with PowerShell code that already works

$computername = "localhost",$env:computername

Get-ciminstance -class win32_logicaldisk -filter "drivetype=3" -ComputerName $computername |
Select @{Name="Computername";Expression={$_.SystemName}},
DeviceID,@{Name="SizeGB";Expression={$_.Size/1GB -as [int]}},
@{Name="FreeGB";Expression = { [math]::Round($_.Freespace/1GB,2)}},
@{Name="PctFree";Expression = { ($_.freespace/$_.size)*100 -as [int]}}