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.

If it is useful, plz mark answer as correct or helpful.
----------------------------------------------------------------
Thanks & Regards
Vikas, VCP50, MCTS on AD, SCJP6.0.
http://vThinkBeyondVM.com
-----------------------------------------------------------------
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.

0 Kudos