Manipulating a -size value

Hi all,
Is there an easy way to modify this code so the output makes the Size or Startingoffset easier to read? Like 1GB etc…

Get-WmiObject win32_diskpartition | Select Systemname, name, size, index, startingoffset


Good morning,

Please use this method when posting code to the forum as it makes it easier for the people working with it.

Guide to Posting Code - Redux - PowerShell Help - PowerShell Forums

Here is an article I found on your topic
Convert bytes to gigabytes with PowerShell – 4sysops

I would recommend using Get-Ciminstance as the Get-WMIObject is deprecated.

I put this together, it should give you the expected results.

Get-Ciminstance win32_diskpartition | Select Name,Index,
@{name="SizeGB";e={[math]::round($_.size /1GB)}},
@{name="OffSetGB";e={[math]::round($_.startingoffset /1GB)}}
1 Like

Thanks for the info, that does it.