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
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
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
Thanks, works like a charm and learned something new 😄