This content has been marked as final.
Show 2 replies
-
1. Re: How to round storage output numbers
AutomationStation May 11, 2017 6:33 AM (in response to AutomationStation) -
2. Re: How to round storage output numbers
mattboren May 11, 2017 6:50 AM (in response to AutomationStation)Hello, AutomationStation -
You can use the Round() method of the .NET class Math to round your numbers. For example, to round to one decimal place:
PS C:\> [System.Math]::Round(123.42324, 1)
123.4
So, for your example, you could use it as such:
Get-VM | Select-Object Name, MemoryGB, NumCpu,
@{n="UsedSpaceGB"; e={[System.Math]::Round($_.UsedSpaceGB, 1)}},
@{n="TotalHDSizeGB"; e={(Get-HardDisk -VM $_ | Measure-Object -Sum CapacityGB).Sum}},
@{n="Network"; e={(Get-NetworkAdapter -VM $_ | Select -Unique -Expand NetworkName)}} | Sort-Object Network
How does that do?