Forum / Remote Desktop Manager - PowerShell Repository

Automating RDM Login? passing credentials to RDMDatasource with powershell?

  • Create an Issue
  • Cancel

Hi,

I'm trying to automate a few things, namely removing sessions based on a variable that is received from another powershell script.
Searched the forum but was unable to find a solution to this problem.

Currently i have a datasource set up in RDM called 'ADMIN' which has all the required permissions to mutate sessions.
I use the following code in powershell to switch the script to the datasource:


Set-RDMCurrentDataSource 37cc52aa-c300-4351-865e-cef5fdfc56b0


i have found i can pass credentials to the datastore using the username and password option


unfortunately when i do this and use get-rdmsession 9 times out of 10, the result is that nothing gets returned, while there are definitely entries in the datasource.


example login:


to store pass in txt file :
(get-credential).password | ConvertFrom-SecureString | set-content ".\rdmpass.txt"


Set-RDMCurrentDataSource 37cc52aa-c300-4351-865e-cef5fdfc56b0 -Username adm_rvergoossen -Password (Get-Content .\rdmpass.txt | ConvertTo-SecureString)


is there a better way to achieve a seamless login? thanks in advance

Clock3 mths

Hello,

I have moved your topic in the PowerShell section on our forum and assigned one of my colleague so that she can analyzed your scenarion and get back to you.

Best regards,



Jeff Dagenais

OFFICE CLOSURE!
Although our various support queues will be monitored for emergencies, Devolutions' offices will be closed on Monday, April 22, 2019.

signaturesignature

Clock3 mths

Hello,

What RDM version are you using?

What data source type are you connected to? If it's Devolutions Password Server, which version are you using?

Could you please try the following to see if this will help to resolve the issue? It is preferable to use the object instead of the GUID of the data source.

$ds = Get-RDMDataSource -Name "Admin"
Set-RDMCurrentDataSource $ds -Username adm_rvergoossen -Password (Get-Content .\rdmpass.txt | ConvertTo-SecureString)

Best regards,



Érica Poirier

OFFICE CLOSURE!
Although our various support queues will be monitored for emergencies, Devolutions' offices will be closed on Monday, April 22, 2019.

signaturesignature

Clock3 mths

Hi,

right now we are on DVLS 5.0.2.0 with RDM client 13.5.6.0.
This weekend after an update we will have DPS 6.1.1.0 and RDM client 14.1.1.0

are there noticable differences? and will it incluse an updated powershell module?

The problem i have with the get-rdmdatasource command is that upon 'getting' the source, i get a credential popup. the get command does not allow a username and password, so that does not work.

This is why i have a Set-RDMCurrentDataSource set to the guid/id of the admin source, which works.

Problem is this only works once (i run get-rdmsession and get all sessions returned), if i run another Set-RDMCurrentDataSource in the same ISE window for example, the get-rdmsession returns nothing.

I have temporarily solved this by running the Set command only once in the testscript and then using a $rdm = $true to define wether the set needs to be run another time:

if (-not $rdm) { Set-RDMCurrentDataSource -id 37cc52aa-c300-4351-865e-cef5fdfc56b0 -Username adm_rvergoossen -Password (Get-Content .\rdmpass.txt | ConvertTo-SecureString); Import-Module "${env:ProgramFiles(x86)}\Devolutions\Remote Desktop Manager\RemoteDesktopManager.PowerShellModule.dll" $rdm = $true }

This allows me to run the script multiple times and get data from get-rdmsession

The behaviour seems weird to me, am i missing something? As i mentioned above, your example does not work because of the credential popup for getting the datasource.

Clock3 mths

Hello,

Thank you for the information.

The reason why RDM PowerShell cmdlets return nothing is because RDM 13.5.6 in combination with a DVLS data source has some cache issues. You should not experience the issue anymore with the latest versions.

About the Get-RDMDataSource when your main data source is set to prompt for the credentials, a workaround is to create an empty local data source as the default opening data source in RDM. So it doesn't prompt for any credentials when the script runs the Get-RDMDataSource cmdlet.

If possible, let us know how your script behaves after the upgrade to DPS 6.1.3 and RDM 14.1.3.

Best regards,



Érica Poirier

OFFICE CLOSURE!
Although our various support queues will be monitored for emergencies, Devolutions' offices will be closed on Monday, April 22, 2019.

signaturesignature

Clock3 mths

Hi,

Thanks for your reply, using the empty data source i am able to get to the others without a credential popup.
I would like to automate the process, is it possible to set the default data source using powershell?

i can find creating the source as xml using the following command, but was unable to find where i can edit the 'rdm startup' or default property of a datasource.

New-RDMDataSource -XML -Filename DefaultXML -Name DefaultXML -SetDatasource


if will notify you of the behaviour after the update, of course.

Clock3 mths

Hello,

It is not possible to set the default data source using the RDM PowerShell module.

Best regards,



Érica Poirier

OFFICE CLOSURE!
Although our various support queues will be monitored for emergencies, Devolutions' offices will be closed on Monday, April 22, 2019.

signaturesignature

Clock3 mths

Hi,

Is there another possibility to achieve this? maybe editing a (config) file for the user that has the data source?

Clock3 mths

Hello,

I'd like to start by mentioning that it would be better to automate using the server automation features, you are using the powershell module that drives RDM, which in turn drives DPS. This is not ideal and introduces a complexity in managing the local cache vs the server content.


We have provided a python SDK, and also have started on a command line tool to perform these tasks in an easier fashion.


That being said, if you install RDM using the portable model, you set the config path using a simple text file named override.cfg. This means, that you could have multiple config files in their own sub folders, and your powershell script would alter the override.cfg file prior to starting RDM. Its kind of stretching our capabilities to their limits... It makes for a complex solution with a lot of chance for errors.



Maurice Côté

signaturesignature

Clock3 mths