VMware Cloud Community
robmatrovemobil
Contributor
Contributor

Attempting to browse the VI Server Inventory Hosts and Clusters view when a datacenter is involved, how to do this?

Hopefully an easy one.

In my virtual center server setup, under "Hosts & Clusters" I have a folder and a datacenter.

With "get-folder -norecursion | get-datacenter -norecursion" I get my datacenter object.

Under that datacenter, I have a cluster, so I thought that "get-folder -norecursion | get-datacenter -norecursion | get-cluster -norecursion" would return my cluster object, but I get nothing.

Under my folder, I have a datacenter and "get-folder -norecursion | get-folder -norecursion | get-datacenter -norecursion" DOES return my datacenter.

If I add a folder to a datacenter in the vi client and I attempt

get-folder -no recursion on that datacenter, then I get two folders named

"vm" and "host" and no folder with name I see under my datacenter in the vi client.

So what's going on with the datacenter objects? How do I traverse the vi server object tree view once I hit a datacenter?

What am I missing/doing wrong?

Rob

0 Kudos
3 Replies
LucD
Leadership
Leadership

The directory structure contains some hidden folders (like for example the "vm" and the "host" folder under a datacenter).

You can use the Managed Object Browser to see that structure (<VCserver>/mob).

A sample script to traverse the folder structure starting from a datacenter can be found in


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

robmatrovemobil
Contributor
Contributor

Thanks for the pointer to the script.

What I want to do is simply get the imediate child objects for a datacenter as seen in the vi client and I have found that the following does the trick for my purposes

given $dc is a datacenter object then

$dc | get-inventory -norecursion | get-cluster -norecursion to get imediate child clusters

$dc | get-inventory -norecursion | get-folder -norecursion to get imediate child folders and I ignore the folder called "Discovered Virtual Machine"

and I hope that

$dc | get-inventory -norecursion | get-vmhost -norecursion will give me child vmhosts but I haven't tried this out.

Rob.

0 Kudos
robmatrovemobil
Contributor
Contributor

oops, i meant to mark this as answered

0 Kudos