VMware Cloud Community
Uridium454
Enthusiast
Enthusiast

Return all of the VMs owned by a particular business group

Just a quick note to help anyone out there that may be looking for a list of VMs owned by a particular business group.  May you find it useful.

Inputs:

vCACCAFE:VCACHost

BusinessGroupName (note: the BG name has been hardcoded below for testing as seen "MyBusinessGroupName")

   

Script:

var service = host.createCatalogClient().getCatalogConsumerResourceService();

var businessGroupObject = vCACCAFEEntitiesFinder.findBusinessGroups(host,"MyBusinessGroupName")[0];

var businessGroupID = businessGroupObject.getId();

System.log("BusinessGroup ID: " + businessGroupID);

var filter = new Array();

filter[0] = vCACCAFEFilterParam.substringOf("organization/subTenant/id", vCACCAFEFilterParam.string(businessGroupID));

var query = vCACCAFEOdataQuery.query().addFilter(filter);

var items = service.getResourcesList(new vCACCAFEPageOdataRequest(query));

//Removing all deployments, as I was only interested in the VM name. Can parse as needed from this point.

for each( var item in items){

     if(item.hasChildren == false){

          System.log("name:" + item.name);

     }

}

1 Reply
vThinkBeyondVM
VMware Employee
VMware Employee

Thanks for sharing.


----------------------------------------------------------------
Thanks & Regards
Vikas, VCP70, MCTS on AD, SCJP6.0, VCF, vSphere with Tanzu specialist.
https://vThinkBeyondVM.com/about
-----------------------------------------------------------------
Disclaimer: Any views or opinions expressed here are strictly my own. I am solely responsible for all content published here. Content published here is not read, reviewed or approved in advance by VMware and does not necessarily represent or reflect the views or opinions of VMware.

Reply
0 Kudos