Hi Support,
My objective is to the Get list of names of all main folders under a specific folder called City\AAAA\
Devolution server version 2024.3.11.0
Powershell version 7.6 installed on my windows 10 VM
Remote Desktop manager entreprise endition 2024.3.28.0
RDP manager is installed on my VM and connected to Secretside server
I need to the Get list only of names of all main folders under a specific folder called City\AAAA\
City\AAAA\
folder a
session 1
session 2
folder b
session 1
session 2
folder c
folder d
folder e
folder f
session 1
folder g
PS C:\Users\user\Desktop\RDM> Get-RDMDataSource
ID : aaaaaa-aaaa-aaaa-aaaa-aaaaaa
IsConnected : False
IsOffline : False
Name : Local Data Source
Type : SQLite
ID : bbbbbb-bbbb-bbbb-bbbb-bbbbbbb
IsConnected : True
IsOffline : False
Name : Secretside
Type : RDMS
Can you please provide the command for that to extract the name for folders and to get as output
"a,b,c,d,e,f,g"
Hello,
Here is the approach to proceed:
# Folder to search
$folder = 'City\AAA'
# Get all main folders
Get-RDMSession -Type Group -GroupName $folder -IncludeSubFolders |
Where { $_.Group -eq "$folder\$($_.Name)" } |
Select -ExpandProperty Name |
Join-String -Separator ','
Let us know if you need any further adjustments.
Best regards,
Maxime
# Import the Devolutions PowerShell module
Import-Module -Name "C:\Program Files\WindowsPowerShell\Modules\Devolutions.PowerShell\2024.3.11\Devolutions.PowerShell.psd1"
# Connect to the RDM data source
$ds = Get-RDMDataSource -Name "db"
Set-RDMCurrentDataSource $ds
# Define the environment path
$ENV = 'City\AAA\database'
$database='database'
# Check if the folder already exists
$existingFolder = Get-RDMSession -Type Group -GroupName '$ENV$database'
if (-not $existingFolder) {
Write-Host "Creating folder: $ENV$database"
# Create the database folder
$databaseFolder = New-RDMSession -Name "database" -Type Group -Group $ENV -SetSession
Set-RDMSession -Session $databaseFolder -Refresh
# Define credentials in an array
$credentials = @(
@{ Name = "aa"; User = "test"; Pass = "bbb" }
@{ Name = "ccc" = "test1"; Pass = "dd" }
@{ Name = "eee"; User = "test2"; Pass = "fff" }
)
# Loop through credentials and create sessions
foreach ($cred in $credentials) {
$database='database\'
$password = ConvertTo-SecureString $cred.Pass -AsPlainText -Force
$session = New-RDMSession -Type Credential -Name $cred.Name -Group "$ENV$database"
$session.ConnectionSubType = "Default"
$session.HostUserName = $cred.User
Set-RDMSessionPassword -Session $session -Password $password
Set-RDMSession -Session $session -Refresh
Write-Host "Created credential: $($cred.Name)"
}
} else {
Write-Host "Folder already exists. Skipping creation."
}
Set-RDMSession: C:\Users\Desktop\RDM\Key.ps1:38
Line |
38 | Set-RDMSession -Session $session -Refresh
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Connection has invalid group specified.
Created credential: bbb
# Import the Devolutions PowerShell module
Import-Module -Name "C:\Program Files\WindowsPowerShell\Modules\Devolutions.PowerShell\2024.3.11\Devolutions.PowerShell.psd1"
# Connect to the RDM data source
$ds = Get-RDMDataSource -Name "db"
Set-RDMCurrentDataSource $ds
# Define the environment path
$ENV = 'City\AAA\database'
# Check if the folder already exists
$existingFolder = Get-RDMSession -Type Group -GroupName "$ENV"
if (-not $existingFolder) {
Write-Host "Creating folder: $ENV"
# Create the database folder
$folderSession = New-RDMSession -Name "database" -Type Group -Group $ENV -SetSession
Set-RDMSession -Session $folderSession -Refresh
# Define credentials in an array
$credentials = @(
@{ Name = "aa"; User = "test"; Pass = "bbb" }
@{ Name = "ccc" = "test1"; Pass = "dd" }
@{ Name = "eee"; User = "test2"; Pass = "fff" }
)
# Loop through credentials and create sessions
foreach ($cred in $credentials) {
$password = ConvertTo-SecureString $cred.Pass -AsPlainText -Force
$session = New-RDMSession -Type Credential -Name $cred.Name -Group "$ENV"
$session.ConnectionSubType = "Default"
$session.HostUserName = $cred.User
Set-RDMSessionPassword -Session $session -Password $password
Set-RDMSession -Session $session -Refresh
Write-Host "Created credential: $($cred.Name)"
}
} else {
Write-Host "Folder already exists. Skipping creation."
}
The folder is created and the first user aa created under it properly
but the second and third users failed with error
Set-RDMSession: C:\Users\Desktop\RDM\Key.ps1:38
Line |
38 | Set-RDMSession -Session $session -Refresh
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Connection has invalid group specified.
Created credential: bbb
# Import the Devolutions PowerShell module
Import-Module -Name "C:\Program Files\WindowsPowerShell\Modules\Devolutions.PowerShell\2024.3.11\Devolutions.PowerShell.psd1"
# Connect to the RDM data source
$ds = Get-RDMDataSource -Name "db"
Set-RDMCurrentDataSource $ds
# Define the environment path
$ENV = 'City\AAA\database'
$database='database'
# Check if the folder already exists
$existingFolder = Get-RDMSession -Type Group -GroupName '$ENV$database'
if (-not $existingFolder) {
Write-Host "Creating folder: $ENV$database"
# Create the database folder
$databaseFolder = New-RDMSession -Name "database" -Type Group -Group $ENV -SetSession
Set-RDMSession -Session $databaseFolder -Refresh
# Define credentials in an array
$credentials = @(
@{ Name = "aa"; User = "test"; Pass = "bbb" }
@{ Name = "ccc" = "test1"; Pass = "dd" }
@{ Name = "eee"; User = "test2"; Pass = "fff" }
)
# Loop through credentials and create sessions
foreach ($cred in $credentials) {
$database='database\'
$password = ConvertTo-SecureString $cred.Pass -AsPlainText -Force
$session = New-RDMSession -Type Credential -Name $cred.Name -Group "$ENV$database"
$session.ConnectionSubType = "Default"
$session.HostUserName = $cred.User
Set-RDMSessionPassword -Session $session -Password $password
Set-RDMSession -Session $session -Refresh
Write-Host "Created credential: $($cred.Name)"
}
} else {
Write-Host "Folder already exists. Skipping creation."
}
The folder is created and the first user aa created under it properly
but the second and third users failed with error
Set-RDMSession: C:\Users\Desktop\RDM\Key.ps1:38
Line |
38 | Set-RDMSession -Session $session -Refresh
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Connection has invalid group specified.
Created credential: bbb
Please check this comment
Hello,
Since you posted this issue in this new thread, we will continue troubleshooting on the new one.
Best regards,
Érica Poirier