VMware Cloud Community
celma972
Contributor
Contributor
Jump to solution

how to get the first level of a tree when running get-folder

Dear All,

Here is my Vcenter folder tree

Vcenter folder tree.JPG

When I run Get-Folder -Type Datacenter, I am getting the following result :

Vcenter folder tree.JPG

Is there anyway to get the first level (Asia and Europe) only?

Thks in advance

JJC

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Try like this then

$parent = Get-Folder -Name Datacenters

Get-Folder -Location $parent -NoRecursion


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

View solution in original post

0 Kudos
6 Replies
LucD
Leadership
Leadership
Jump to solution

These are yellow folders, so they should be located under the hidden 'vm' folder.

The NoRecursion switch limits the results to the first level folders.

Get-Folder -Location (Get-Folder -Name vm) -NoRecursion


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

0 Kudos
celma972
Contributor
Contributor
Jump to solution

The result with you suggestion give the following

get-folder.JPG

I need to have Asia and Europe in the result without their subfolders.

JJC.

0 Kudos
LucD
Leadership
Leadership
Jump to solution

So which is the parent of Asia and Europe?
I can't see that on your screenshot.


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

0 Kudos
celma972
Contributor
Contributor
Jump to solution

This is the Vcenter server as shown herewith

Vcenter tree.JPG

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Try like this then

$parent = Get-Folder -Name Datacenters

Get-Folder -Location $parent -NoRecursion


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

0 Kudos
celma972
Contributor
Contributor
Jump to solution

That's do the trick

Thks a lot

JJC

0 Kudos