VMware Cloud Community
nooobus12
Contributor
Contributor
Jump to solution

How to round up Provisioned and usedspace

Hello VMWare community, 

I am new to PowerCLI so forgive me if I sound like an amateur.

 It may be a simple solution, but I'm trying to build a script to automate Exports in the future and right now I'm stuck rounding up space used and provisionedspace. What am I missing here?

Thank you

Get-View -ViewType VirtualMachine -Property Name,Runtime.PowerState,Config.Hardware,Config.GuestFullName,Summary.Storage | Select-Object Name,
@{n="PowerState"; e={$_.Runtime.PowerState}},
@{n="NumCPU"; e={$_.Config.Hardware.NumCPU}},
@{n="MemoryGB"; e={$_.Config.Hardware.MemoryMB / 1KB}},
@{N="Configured OS";E={$_.Config.GuestFullName}},
@{n="ProvisionedSpaceGB"; e={($_.Summary.Storage.Committed + $_.Summary.Storage.Uncommitted) / 1GB}},
@{n="UsedSpaceGB"; e={$_.Summary.Storage.Committed / 1GB}} | Export-Csv -Path C:\Temp\tet.csv

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

With PS you can call the .NET methods, in this case the [Math]:Round() method

@{n = "ProvisionedSpaceGB"; e = {[math]::Round(($_.Summary.Storage.Committed + $_.Summary.Storage.Uncommitted) / 1GB,1) } },
@{n = "UsedSpaceGB"; e = { [math]::Round($_.Summary.Storage.Committed / 1GB,1) } } | Export-Csv -Path C:\Temp\tet.csv


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
2 Replies
LucD
Leadership
Leadership
Jump to solution

With PS you can call the .NET methods, in this case the [Math]:Round() method

@{n = "ProvisionedSpaceGB"; e = {[math]::Round(($_.Summary.Storage.Committed + $_.Summary.Storage.Uncommitted) / 1GB,1) } },
@{n = "UsedSpaceGB"; e = { [math]::Round($_.Summary.Storage.Committed / 1GB,1) } } | Export-Csv -Path C:\Temp\tet.csv


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
nooobus12
Contributor
Contributor
Jump to solution

Thanks, works like a charm and learned something new 😄

0 Kudos