SCRIPT RETURN FIRST FOLDER

SCRIPT RETURN FIRST FOLDER

avatar

Hello,

discover the powershell commands and try to get the list of the first level folders. Example, the structure is:

A

A\AAA

A\AAA\AAAA

B

B\BBB

C

D

D\DDD

I would like to recover in powershell the list of folder:A

B

C

DCan you help me please ?

Thanks

Best regards

All Comments (2)

avatar

Hi,

There are multiple ways to get first level folders using the PowerShell cmdlets. Here’s two ways:

1. Explanation: When the name and the group is same thing it means that the folder doesn’t have parents and thus is the first level folder

Get-RDMSession | Where-Object {$_.ConnectionType -eq "Group" -and $_.Name -eq $_.Group}

OR

2. Explanation: When the group doesn’t contain “\” it means that the folder doesn’t have parents and thus is a first level folder

Get-RDMSession | Where-Object {$_.ConnectionType -eq "Group" -and $_.Group -inotmatch “\”}

Best regards,

Olivier Désalliers

avatar

Hi,

thank you for your return, it works very well

Best Regards