Forum / Remote Desktop Manager - PowerShell Repository

SCRIPT RETURN FIRST FOLDER

  • Create an Issue
  • Cancel

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
D

Can you help me please ?
Thanks
Best regards

Clock6 mths

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

signaturesignature

Clock6 mths

Hi,

thank you for your return, it works very well
Best Regards

Clock6 mths