I am using the following command to check space on remote server:

Get-WmiObject -Class win32_logicalDisk -ComputerName computer-name | Select Name,@{n="Free";e={[math]::trun
cate($_.freespace / 1GB)}}, @{n="Total Size";e={[math]::truncate($_.size / 1GB)}}

It outputs:

Name Free Total Size
---- ---- ----------
C:     13         59
D:      0          0

However, the actual space is: 10.5 free from 59.8. It's like it's using int, not float. Anyone know how can I change it in order to show the real float values?

2 Answers 2


Found it. It seems I need to use abs instead of the truncate function.

Get-WmiObject -Class win32_logicalDisk -ComputerName computer-name | Select Name,@{n="Free";e={[math]::abs(
$_.freespace / 1GB)}}, @{n="Total Size";e={[math]::abs($_.size / 1GB)}}

or Get-WmiObject -Class win32_logicalDisk -ComputerName computer-name | Select Name,@{n="Free";e={[($.freespace / 1GB) -as [int]}}, @{n="Total Size";e={$.size / 1GB -as [int])}}

  • Welcome to Super User! Please take the tour and read through the help center center. Here is a guide on How to Ask and How to Answer. Please note the conventions for formatting How do I format my posts using Markdown or HTML. Code-only answers are considered low quality: make sure to provide an explanation what your code does and how it solves the problem. Feb 9, 2021 at 12:55
  • Before answering an old question having an accepted answer (look for green ✓) as well as other answers ensure your answer adds something really new or is otherwise helpful in relation to them. Feb 9, 2021 at 12:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .