Forum / Remote Desktop Manager - PowerShell Repository

Edit datasource username with Powershell

  • Create an Issue
  • Cancel


I am not sure if this is the only/right way to do it but, I want all our users to switch to O365 Authentication, not really sure how to distribute Datasource to all of them (since their installed version is almost always newer than the one we are serving through our ConfigMgr) but I can enforce reinstallation with new datasorce (and hopefully users will follow instructions and replace configuration when asked on first start)...
The problem I am currently struggling with is how to populate username with UPN, I don't want users to be aksed for username everytime they sign in. In GUI you enter your username, AFAIK there is no variable to get UPN form environment (works for samaccountname with %username%).
So I build the script that get UPN but I have no idea how to save it to Datasource:
Import-Module "${env:ProgramFiles(x86)}\Devolutions\Remote Desktop Manager\RemoteDesktopManager.PowerShellModule.dll"

#get UPN for the user
$objDomain = New-Object System.DirectoryServices.DirectoryEntry
$Searcher = New-Object System.DirectoryServices.DirectorySearcher
$Searcher.SearchRoot = $objDomain
$Searcher.PageSize = 1
$Searcher.Filter = "(SAMAccountName=" + $env:USERNAME + " ) ";
$Searcher.SearchScope = "Subtree"
$searcher.PropertiesToLoad.Add("userprincipalname" )
$object = $searcher.FindOne()

#manipulate DataSource
$o365DS=Get-RDMDataSource "RDM - O365Auth"
Set-RDMDataSourceProperty -ID $($o365DS.ID) -username $UPN
Unfortunatelly get-help on Set-RDMDataSorceProperty doesn't give me anything usefull. Set-RDMCurrentDataSource has an Username attribute, but I guess it doesn't set the value, only uses it...

Clock3 mths


It is not actually possible to set and save the username in the data source object using the RDM PowerShell module. Let me check with our engineering department and will get back to you once I will get any information about it.

Best regards,

Érica Poirier


Clock3 mths