Hi all,
I need to export a nice, simple report, with two columns:
Organization Name | Number of VMs
I need all the VMs in each Org (both running and not running).
I know there's a function getting this number, but I do not know how to put it in a script so I can get it for each (guess we can use this loop, right?) organization in the vcd...
(Get-Org ORG_NAME | Get-CIVM).count
Thanks for the help!
Martin.
Thread moved to the vCloud Director PowerCLI community
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi Martin,
you can try the following PowerCLI command:
Get-Org | Select-Object -Property Name,@{N="VMCount";E={($_ | Get-CIVM).count}}
A thousand thank you !
Just one question, is there any reason the two columns are so separated? (It doesn't matter when you export it to csv, but I just wonder why...).
That is the default PowerShell formatting for a table. If you want to have the columns together then you can pipe the output to Format-Table -AutoSize. E.g.:
Get-Org | Select-Object -Property Name,@{N="VMCount";E={($_ | Get-CIVM).count}} | Format-Table -AutoSize
Awesome!
Thanks again