Creating folder and RDP sessions inside that folder using powershell script

Creating folder and RDP sessions inside that folder using powershell script

avatar

Hi Devolution,

My objective is to create a folder and RDP session inside that folder after going to a specific folder using a powershell script
Devolution server version 2022.1.10.0
Powershell version 7.2 installed on my windows 10 VM
Remote Desktop manager entreprise endition 2022.2.29.0

RDP manager is installed on my VM and connected to devolution server as shown per screenshot attached.
I need to create folder and RDP session inside that folder which should be synchronized to all users.

PS C:\Users\user> 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 : False
IsOffline : False
Name : Secretserver
Type : RDMS


PS C:\Users\user> Get-RDMCurrentDataSource
WARNING: This application requires a Devolutions Server version greater or equal than 2022.3.0.0.

Please contact your administrator and update the server.

ID : bbbbbb-bbbb-bbbb-bbbb-bbbbbbb
IsConnected : False
IsOffline : False
Name : Secretserver
Type : RDMS



1-to which datasource should connect is this case ?

2-inside the powershell script, should i conenct to devolution server as command A or simply set the proper source name and proceed by creating the folder and RDP sessions as command B
command A: Connect-RdmServer -ServerUrl "https://secretserver.xxxx.xx" -Credential $credential
command B:$rdmDataSource = Get-RDMDataSource -Name "xxxxxx"
Set-RDMCurrentDataSource -DataSource $rdmDataSource
what is difference by using the above two ways:

3-is there any sample for such script to connect to the above correct ENV ? please note that MFA is already enabled .

4-PS C:\Users\user> Install-Module -Name Devolutions.PowerShell
WARNING: Unable to resolve package source 'https://www.powershellgallery.com/api/v2'.
Install-Package: No match was found for the specified search criteria and module name 'Devolutions.PowerShell'. Try Get-PSRepository to see all available registered module repositories.


but if i run the command Get-Command -Module Devolutions.PowerShell , i am ble to get list of commands like Get-RDMDataSource

secretserverlocaldevoPS C:\Users\user> Get-PSRepository

Name InstallationPolicy SourceLocation
---- ------------------ --------------
PSGallery Untrusted https://www.powershellgallery.com/api/v2

Please advise
Thanks

secretserver.PNG

local.PNG

devo.PNG

All Comments (6)

avatar

Hello,

Thank you for contacting us on that matter.

First of all, as you are using a mix of versions of our products, it will certainly not works as expected. With the DVLS version you are using, the RDM PowerShell module you should use is version 2022.1.3.4 you can get on PSGallery.
https://www.powershellgallery.com/packages/RemoteDesktopManager/2022.1.3.4

Please see the note about the versions on this page.
https://docs.devolutions.net/kb/devolutions-powershell/remote-desktop-manager/rdm-powershell-core-module/#powershell-installation

For your questions :
1- You should connect to the RDMS type data source named Secret Server.
2- The method to connect to a data source is the one you described in command B. The other cmdlet is no longer available.
3- The command B you are using to connect should work with the proper RDM PowerShell module version.
4- As you are using an older DVLS version, then the Devolutions.PowerShell module won't work as it has been released with RDM and DVLS version 2023.1 and above. So using the previous RDM PowerShell module should solve your connectivity issues. Please note that you will have to first uninstall the Devolutions.PowerShell module prior to install the RDM one.

Let us know if you have further questions or issues with your PowerShell scripts.

Best regards,

Érica Poirier

avatar

Hello,

Thanks for support.
yes , i have already install Remote desktop manager powershell module as the version installed is 2022.2.29 and everything is working fine related to the script below .

Import-Module -Name "C:\Program Files\WindowsPowerShell\Modules\Devolutions.PowerShell\2022.2.2\RemoteDesktopManager.psd1"
# Connect to the RDM data source
$ds = Get-RDMDataSource -Name "secretserver"
Set-RDMCurrentDataSource $ds

$path="x"
$foldername = New-RDMSession -Name newfolder -Type "Group" -Group $path -SetSession
Set-RDMSession -Session $foldername -Refresh
$sessionAS = New-RDMSession -Type RDPConfigured -Name testserver -Group "" -Host "host123"
Set-RDMSession -Session $sessionAS -Refresh

The sesssion was created properly with default port 3389 .
I need to customize port number and password as per screenshot attached.
can you please advise the parameters for the above goal or how should be applied as i was not able to find the related parameters after checking all options for New-RDMSession command

Regards,
Thanks.

RDM.PNG

avatar

Hello,

Thank you for your feedback.

You will find on the following online documentation page the method to find every property's name to be used in your PowerShell script.
https://docs.devolutions.net/rdm/windows/powershell-scripting/tips-tricks/#reverse-engineering-an-entry's-structure

For the username and password, you can use the following method to do so.

$password = ConvertTo-SecureString "MyPassword" -AsPlainText -Force
Set-RDMSessionPassword -Session $sessionAS -Password $password
$username = "MyUsername"
Set-RDMSessionUserName -Session $sessionAS -UserName $username
Set-RDMSession $sessionAS -Refresh


Let us know if you have further questions about it.

Best regards,

Érica Poirier

avatar

Hello Erica,

Thanks for your reply.
The above is tried and the session is created with the username and password filled in the textboxes. "credentials screenshot attached "
But my purpose is to the create it with adjusting the settings Credentials to Linked (Vault) and choosing a specific credentials entry "Customer_ENVs\xxx " inside the the session created in RDM " Vault screenshot attached " instead of filling username and password in the textboxes.

Can you please advise if feasible ?

Regards,
Thanks.

Vault.PNG

credentials.PNG

avatar

Hello,

Please note that proprites set for the session and settings are configured as excepted .
Thanks for your support

Regards,

avatar

Hello,

Thank you for your feedback.

Sure it's possible to set the Credentials property to Linked (Vault) and bind it to an existing credential entry. You just have to set the CredentialConnectionID property with the ID of the credential entry like this. No need to use the Set-RDMSessionPassword cmdlet.

$sessionAS.CredentialConnectionID = "401f155d-8669-4645-b2ec-309c704bda9d"
Set-RDMSession $sessionAS - Refresh


Let us know if that helps.

Best regards,

Érica Poirier