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 ?
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?
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