Get-WmiObject Win32_LogicalDisk | Format-Table -autosize DeviceID,@{Label="Size(G)";Expression={[math]::round($_.Size/1GB,2)}},@{Label="Freespace(G)";Expression={[math]::round($_.FreeSpace/1GB,2)}},@{Label="Percent";Expression={"{0:P2}" -f ($_.Size/1GB - ($_.Size/1GB - $_.Freespace/1GB) / $_.Size/1GB)}}
All you need to look at is the last Expression statement. For some reason, it's coming back as:
DeviceID Size(G) Freespace(G) Percent
-------- ------- ------------ -------
C: 93.16 54.73 9,315.82 %
D: 257.71 202.51 25,770.63 %
I understand Order of Operations is causing itn to show as 9,315% but anytime I try taking away paranthesis or adding some to ensure the first part of the calculation gets calcualted first, nothing ends up showing in Percent.
Any ideas?