To accurately get the free space and total size of each drive in gigabytes using PowerShell, you can modify the previous command slightly. Here’s a corrected version that ensures the free space and total size are displayed properly:
Get-PSDrive -PSProvider FileSystem | Format-Table Name, Used, Free, @{n="TotalSize(GB)";e={[math]::Round(($_.Used + $_.Free) / 1GB, 2)}}, @{n="FreeSpace(GB)";e={[math]::Round($_.Free / 1GB, 2)}}