VMware Cloud Community
tinchito7
Contributor
Contributor

vCD - Get VM quantity of each Organization

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.

5 Replies
LucD
Leadership
Leadership

Thread moved to the vCloud Director PowerCLI community


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

0 Kudos
RvdNieuwendijk
Leadership
Leadership

Hi Martin,

you can try the following PowerCLI command:

Get-Org | Select-Object -Property Name,@{N="VMCount";E={($_ | Get-CIVM).count}}

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
tinchito7
Contributor
Contributor

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...).

0 Kudos
RvdNieuwendijk
Leadership
Leadership

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

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
tinchito7
Contributor
Contributor

Awesome!

Thanks again Smiley Happy

0 Kudos