Hi,
I am working on a script to create and delete RDM sessions for servers, as part of that i wanted to populate all the folders till level two [ i mean only folders inside root folder and not its subfolders and entries inside.] as variable for using in script so i can select appropriate folder to create my new entry inside of that.
Suppose I have root folder called CST and i have subfolders like A, B, C , D for the products we have...these A,B,C,D also has subfolders and entries inside them but i want to export only A,B,C,D and not folders or entries inside them.
is it possible to do it?
My Current script is as follows:
=================
Import-Module "${env:ProgramFiles(x86)}\Devolutions\Remote Desktop Manager\RemoteDesktopManager.PowerShellModule.psd1"
#get datasource and set it as current datasource to use as default
$datasource = Get-RDMDataSource #-Name CloudSolutions
Set-RDMCurrentDataSource $datasource[0].ID
$sessions = Get-RDMSession | where {$_.ConnectionType -eq "Group"};
$CSVFileName = $PSScriptRoot + '\LimitedExport.csv'
Write-Output "writing to $CSVFileName"
# simply add to the -property filter to have more fields in your output
# note that passwords require more work and are covered in another sample
$sessions | Select-Object -property Name, Group | export-csv $CSVFileName -notypeinformation
========================
it returns me csv file with all the folders in entire vault.
i am trying to find solution myself but if you can help me then i guess i will be able to save some of my time.
Thanks,
Ramdas
Hello,
Thank you for reaching out to Devolutions support. Only a small change would need to be done here.
$sessions = Get-RDMSession | where {$_.ConnectionType -eq "Group" -and $_.Group.Split('\').Length -le 2}
Let me know if this works as intended.
Best regards,
Eric St-Martin
Hello Eric,
That's perfect. works very well. Thank you
Regards,
Ramdas
Hi Ramdas,
No problem, glad to hear it is working.
Have a great weekend!
Best regards,
Eric St-Martin