$drives = Get-PSDrive -PSProvider FileSystem | ForEach-Object { $driveLetter = $_.Name; $drive = Get-WmiObject Win32_LogicalDisk -Filter "DeviceID='${driveLetter}:'"; $driveName = $drive.VolumeName; $usedSpaceGB = [math]::Round(($_.Used/1GB), 2); $freeSpaceGB = [math]::Round(($_.Free/1GB), 2); $totalSpaceGB = [math]::Round(($usedSpaceGB + $freeSpaceGB), 2); $usedPercent = [math]::Round((($usedSpaceGB / $totalSpaceGB) * 100), 2); [PSCustomObject]@{ Name = "$driveLetter ($driveName)"; UsedSpaceGB = $usedSpaceGB; FreeSpaceGB = $freeSpaceGB; TotalCapacityGB = $totalSpaceGB; UsedPercent = $usedPercent } }; $totalUsed = [math]::Round(($drives | Measure-Object UsedSpaceGB -Sum).Sum, 2); $totalFree = [math]::Round(($drives | Measure-Object FreeSpaceGB -Sum).Sum, 2); $totalCapacity = [math]::Round(($drives | Measure-Object TotalCapacityGB -Sum).Sum, 2); $overallPercent = [math]::Round(($totalUsed / $totalCapacity * 100), 2); $drives += [PSCustomObject]@{ Name = "Total"; UsedSpaceGB = $totalUsed; FreeSpaceGB = $totalFree; TotalCapacityGB = $totalCapacity; UsedPercent = $overallPercent }; $drives | Format-Table -AutoSize