VMware Cloud Community
miko201110141
Contributor
Contributor

get-folder filter

I want to report our vSphere farm and need to report wich datacenter is located in which folder. The get-folder gives an output of much more related objects as i need. Is there a filter parameter that shows only the folders in the Hosts and Clusters view ?

0 Kudos
2 Replies
mattboren
Expert
Expert

Hello, miko-

If you want to get the folders that are directly below the top level in the Hosts and Clusters view in the vSphere client, you can do:

Get-Folder Datacenters | Get-Folder -NoRecursion

If you are trying to get all datacenters and the name of the folder in which they reside, try out:

## get all datacenters; list their name and parent folder name
Get-Datacenter | Select Name,ParentFolder

Are those the types of things that you are wanting to do?

0 Kudos
chriswahl
Virtuoso
Virtuoso

Another take on it would be to list out each folder and the VM that resides inside of it.

$DC = 'datacenter_name'
 Get-VM -Location (Get-Datacenter $DC)| Sort -Property folder,name | Select folder,name
VCDX #104 (DCV, NV) ஃ WahlNetwork.com ஃ @ChrisWahl ஃ Author, Networking for VMware Administrators
0 Kudos