Einsener36
Einsener36

Reputation: 5

How do round memory size

I have this script line:

Get-WmiObject Win32_ComputerSystem | Select-Object  TotalPhysicalMemory, @{Name="GB";Expression={$_.TotalPhysicalMemory/1GB}}

How to round this result 2 separate places after coma. result at the moment is enter image description here

Upvotes: 0

Views: 847

Answers (1)

Doug Maurer
Doug Maurer

Reputation: 8868

You can use the format string operator and specify the number of decimal places like this

Get-WmiObject Win32_ComputerSystem |
  Select-Object TotalPhysicalMemory, 
                @{Name="GB";Expression={"{0:n2}" -f ($_.TotalPhysicalMemory/1GB)}}

Upvotes: 2

Related Questions