So I've made a script to create users in AD that utilizes GUI in order for my helpdesk to use it. Recently I decided to add some code for script to import data into RDM - basically credentials of said user (login, mail, password) and radmin connection (username as connection name and hostname).
However, upon first launch of script - RDM module throws this error https://i.imgur.com/5mszt23.png
Also it takes like 20 seconds to proceed a single user import and it's certainly RDM-import part, because once I remove this function - everything else takes less than a second. It's certainly because of Update-RDMUI function but if I remove it - it just creates empty credentials entry.
Here's code:function fImportIntoRDM { [string]$RDMgroup = "ScriptImported" #static folder name [string]$RDMrecordname = $fullname #string, comes from GUI form [string]$RDMusername = $login #string, comes from GUI form [string]$RDMdomain = $emailaddress #string, comes from GUI form [string]$RDMhostname = $hostnameTextBox.text #string, comes from GUI form $RDMpassword = $randomizedpassword | ConvertTo-SecureString -AsPlainText -Force if (-not (Get-Module -Name "RemoteDesktopManager.PowerShellModule")) { Import-Module "${env:ProgramFiles(x86)}\Devolutions\Remote Desktop Manager\RemoteDesktopManager.PowerShellModule.psd1" Update-RDMUI Set-RDMCurrentDataSource -ID "202c12de-2530-4625-9132-89d9843c36f5" } if ($TSDCheckBox.Checked -eq $false) { #NON-TSD => create folder, than create credential + radmin entries inside #create folder for user $RDMuserfolder = New-RDMSession -Type "Group" -Name $RDMrecordname -Group $RDMgroup $RDMuserfolder.ImageName = "SampleUserBlue" Set-RDMSession -Session $RDMuserfolder -Refresh #create credential record type $RDMuserCredentials = New-RDMSession -Host $RDMhostname -Type "Credential" -Name $RDMrecordname -Group $($RDMuserfolder.Group) Set-RDMSession -Session $RDMuserCredentials Update-RDMUI Set-RDMSessionUsername -ID $RDMuserCredentials.ID $RDMusername Set-RDMSessionDomain -ID $RDMuserCredentials.ID $RDMdomain Set-RDMSessionPassword -ID $RDMuserCredentials.ID -Password $RDMpassword if ($hostnameTextBox.text.Length -eq 0) { #if hostname is empty $RDMrecordname += [string]" fill in hostname!" #add note that it's empty to radmin connection's name } #create radmin connection $RDMcreateRadmin = New-RDMSession -Host $RDMhostname -Type "Radmin" -Name $RDMrecordname -Group $($RDMuserfolder.Group) Set-RDMSession -Session $RDMcreateRadmin } else { #TSD USER - ONLY CREDENTIALS WITHOUT FOLDER AND RADMIN #create credential record type $RDMuserCredentials = New-RDMSession -Host $RDMhostname -Type "Credential" -Name $RDMrecordname -Group $RDMgroup Set-RDMSession -Session $RDMuserCredentials Update-RDMUI Set-RDMSessionUsername -ID $RDMuserCredentials.ID $RDMusername Set-RDMSessionPassword -ID $RDMuserCredentials.ID -Password $RDMpassword }}
Hello,
What RDM version are you using?
What data source type are you connected to?
If it is Devolutions Password Server, what version are you using?
To help improving performances, please use the session variable instead of the session ID to set the username and password.
Here is a sample you could use :#create credential record type$RDMuserCredentials = New-RDMSession -Host $RDMhostname -Type "Credential" -Name $RDMrecordname -Group $($RDMuserfolder.Group)Set-RDMSessionUsername -Session $RDMuserCredentials $RDMusernameSet-RDMSessionDomain -Session $RDMuserCredentials $RDMdomainSet-RDMSessionPassword -Session $RDMuserCredentials -Password $RDMpasswordSet-RDMSession -Session $RDMuserCredentials
And at the beginning of the script, please try the following to see if this will help to not get the AD_CreateUsers_v2.exe error. Not sure if it's related!
Please adapt the data source name in that portion of the script!if (-not (Get-Module -Name "RemoteDesktopManager.PowerShellModule")) { Import-Module "${env:ProgramFiles(x86)}\Devolutions\Remote Desktop Manager\RemoteDesktopManager.PowerShellModule.psd1" $ds = Get-RDMDataSource -Name "PutYourDataSourceNameHere" Set-RDMCurrentDataSource $ds Update-RDMUI }
Best regards,
Érica Poirier
Hello, Erica, thank you for reply.
I don't remember exact version and can't check right now since it's at my work computer. It's 14.something and prior posting I made sure to try to update - said I don't need to because version is latest.
As for data source - it's mssql db.
I'll try your advises and reply back once I'll get back at my workplace.
Good morning.
14.1.3.0 64bit
It's SQLServer.
That doesn't work. New entry with "credential" type is created, it has correct name, but "inside" fields username, domain and password are empty and no warnings or errors in powershell. I made sure that $RDMusername, $RDMdomain and $RDMpassword variables are not empty, and have correct datatype - string for first 2 and securestring for password. It even doesn't work if I get rid of variables:$RDMuserCredentials = New-RDMSession -Host "HostName" -Type "Credential" -Name "RecordName" -Group "ScriptImported"Set-RDMSessionUsername -Session $RDMuserCredentials "username"Set-RDMSessionPassword -Session $RDMuserCredentials -Password ("passw0rd" | ConvertTo-SecureString -AsPlainText -Force )Set-RDMSession -Session $RDMuserCredentials
It doesn't help either. Not matter how I run my script - from compiled exe or just running *.ps1 from powershell ise x64 - I still get that warning every first launch (pic https://i.imgur.com/inGdaul.png). Everything works as intended afterwards, it's not in fact critical, just annoying.
I also found this topic from 2 years ago with similar issue on Deutch forums https://forum.devolutions.net/topic28230-rdm-module-und-eigene-powershell-gui.aspx however issue still persist.
This actually suppresses this warning:$ds = Get-RDMDataSource -Name "rdm" [b]-WarningAction SilentlyContinue[/b]
Hello,
Thank you for your feedback and good catch about the -WarningAction switch.
I will check with the engineering team to know if they have another solution for your performance problem for the entry creatrion. I will keep you in touch once I will get some information about it.
Best regards,
Érica Poirier
Any updates? Creating and editing entries is still a very slow process, along with module import itself, btw.
Hello,
Sorry but no new updates on this behavior.
Have you tried the latest RDM version 2019.1.30? Just be aware that this version will require a database upgrade. If you are not already on that version and don't want to update it yet as all your colleagues will have to update their RDM too, you can try it on a local data source with RDM installed as a Portable version.
On a previous post, you have mentioned that using the -Session switch didn't work. I am still unable to reproduce this issue but let me check tomorrow with another teammate if we can reproduce that issue.
Best regards,
Érica Poirier