A few weeks ago i was really happy, i finally figured out how to connect to DLVS without having a client installed.
Below code works with 2022.1.0.6 (5.1 and core)
With 2022.1.0.7 i just get "datasource not connected" when i try to query with Get-RDMSession
"connecting" doesn't give an error or something.
The release notes didn't mention any changes.
Consider the following code:
function Connect-RDMDataSource {
<#
.SYNOPSIS
Connects RDM to DPS datasource and sets datasource to current.
.DESCRIPTION
The new PowerShell cmdlets for Remote Desktop Manager need a little help when
connecting to a Devolutions Password Server backend. By creating a blank XML
as a connection override, RDM is able to successfully connect to the DPS backend
using application credentials.
.EXAMPLE
Connect-RDMDataSource -dsname mydvs -dsurl https://myserver.mydomain.com/dps -appkey c13fd404-3445-11ec-8d3d-0242ac130003 -appsecret WjO4kwTEq21gVzTufUZlButjRC74Pnp7fe6x95kxDvK7vJigSZyvvkj2N6iGLaO2
.NOTES
Note: the RDM cmdlets will thrhow a DllNotFoundException if SQLite.Interop.dll is not installed. These errors are
benign and cannot be hidden with erroraction variables.
#>
[CmdletBinding()]
PARAM(
[Parameter(Mandatory=$true,
ValueFromPipeline=$false,
HelpMessage = 'A name for the DVLS datasource. This can be any value you want.')]
[String]$dsname,
[Parameter(Mandatory=$true,
ValueFromPipeline=$false,
HelpMessage = 'The URL of the Devolutions Password Server as it is in RDM (example, "https://myserver.mydomain.com/dps")')]
[ValidateScript({
if ($_ -match '((http|https)://).*'){
$true
} else {
throw "dsurl must be a url, i.e., https://myserver.mydomain.com/dps"
}
})]
[String]$dsurl,
[Parameter(Mandatory=$true,
ValueFromPipeline=$false,
HelpMessage = 'The application key created in DPS. See https://helpserver.devolutions.net/webinterface_applications.html for more information')]
[ValidateScript ({
if ($_ -match '^[{]?[0-9a-fA-F]{8}-([0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}[}]?$'){
$true
} else {
throw "appkey must be in GUID format, i.e., c13fd404-3445-11ec-8d3d-0242ac130003"
}
})]
[String]$appkey,
[Parameter(Mandatory=$true,
ValueFromPipeline=$false,
HelpMessage = 'The application secret created in DPS. See https://helpserver.devolutions.net/webinterface_applications.html for more information')]
[ValidateScript ({
if ($_.length -eq 64){
$true
} else {
throw "appsecret should be 64 characters is length. See https://helpserver.devolutions.net/webinterface_applications.html for more information"
}
})]
[String]$appsecret
)
process{
$TempFile = New-TemporaryFile
Set-Content $tempfile '<?xml version="1.0"?>'
Add-Content $tempfile '<Option></Option>'
$override = Get-RDMPowerShellOverride
$override.OptionFilePath = $TempFile
Set-RDMPowerShellOverride
$ds = New-RDMDataSource -DVLS -Name $dsname -Server $dsurl -SetDatasource -WarningAction SilentlyContinue
Set-RDMDatasourceProperty $ds -Property "ScriptingTenantID" -Value $appkey
Set-RDMDatasourceProperty $ds -Property "ScriptingApplicationPassword" -Value $appsecret
Set-RDMDataSource $ds
Set-RDMCurrentDataSource $ds
remove-item $TempFile
}
}
$license = Get-RDMRegistrationInfo
$license.Name = 'Remote Desktop Manager'
$license.Email = $env:devolutions_license_user
$license.Serial = $env:devolutions_license_key
Set-RDMRegistrationInfo $license
$TenantID = $env:devolutions_tenant_id
$Password = $env:devolutions_secret_password
$dsname = "mydps"
$dsurl = "https://dps.hostname.com/dps"
Connect-RDMDataSource -dsname $dsname -dsurl $dsurl -appkey $TenantID -appsecret $Password
$RDMSessions = Get-RDMSessionHi,
Indeed, 2022.1.0.7 doesn't directly have much modifications. However, since our code is mostly shared, there could be something different preventing your script from working.
Could you try runnung Get-RDMDiagnostic right after $RDMSessions = Get-RDMSession ? That will evaluate the license to make sure 2022.1.0.7 doesn't think it's invalid.
Jonathan Lafontaine
Good morning. Thank you for your response.
I tested it, and this is the output.
<Here i run the block of code from my previuos post. below is the output>
Registration successful
Get-RDMSession : Connection not found.
At line:90 char:16
+ $RDMSessions = Get-RDMSession
+ ~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Get-RDMSession], Exception
+ FullyQualifiedErrorId : 0,RemoteDesktopManager.PowerShellModule.GetRDMSessionCommand
PS C:\Windows\system32> Get-RDMDiagnostic
Serial LicenseType IsLicenseValid IsLicenseExpired
------ ----------- -------------- ----------------
7ZE7B--blahblah-redactedthis None True FalseHi,
I don't think the license is the problem. The license type none is a bit weird but is it considered valid and it is not expired.
I could send you a custom build with more logging to try and pin point the issue.
That being said, why are you creating a new opton file and data source every time?
Jonathan Lafontaine
The build would be welcome, i'm curious why it doesn't work :)
The reason i do it, is because "it works every time".
i could perhaps improve this function, and i probably will :)
I reuse the function in alot of scripts, basically every time whenever i need passwords.
If people change passwords in devolutions, i don't have to change them i'm my scripts.
This is the output with the debugbuild:
This is a test This is a test This is a test Registration successful This is a test This is a test This is a test Message: An error occurred while sending the request. Stack: at Devolutions.Server.ApiWrapper.RDMSWebClient.RunSynchronous[T](Task`1 task) at Devolutions.RemoteDesktopManager.Business.DataSources.RDMSWebApiClient.<GetServerInformation>b__136_0() at Devolutions.RemoteDesktopManager.Business.DataSources.RDMSWebApiClient.ExecuteAnonymousAction[T](ExecuteActionDelegate`1 action) at Devolutions.RemoteDesktopManager.Business.DataSources.RDMSWebApiClient.GetServerInformation() at Devolutions.RemoteDesktopManager.Business.DataSources.RDMSConnectionDataSource.ForceLoadServerInfo() at Devolutions.RemoteDesktopManager.Business.DataSources.RDMSConnectionDataSource.Login(Boolean useCredentials) at Devolutions.RemoteDesktopManager.Business.DataSources.RDMSWebApiClient.get_WebClient() at Devolutions.RemoteDesktopManager.Business.DataSources.RDMSWebApiClient.<GetRepositories>b__126_0() at Devolutions.RemoteDesktopManager.Business.DataSources.RDMSWebApiClient.RetryAction[T](ExecuteActionDelegate`1 action, String label) at Devolutions.RemoteDesktopManager.Business.DataSources.RDMSWebApiClient.ExecuteAction[T](ExecuteActionDelegate`1 action, ExecuteActionLogMode logMode) at Devolutions.RemoteDesktopManager.Business.DataSources.RDMSWebApiClient.ExecuteActionMultipleData[T](ExecuteActionDelegate`1 action) at Devolutions.RemoteDesktopManager.Business.DataSources.RDMSWebApiClient.GetRepositories() at Devolutions.RemoteDesktopManager.Business.DataSources.RDMSSecuritySubDataSource.GetRepositories(Boolean includeDefault) at Devolutions.RemoteDesktopManager.Business.DataSources.RDMSConnectionDataSource.GetDataSourceSettings() at Devolutions.RemoteDesktopManager.Managers.ConnectionManager.LoadDataSourceSettingsFromDataSource(ConnectionEngine engine) at Devolutions.RemoteDesktopManager.Managers.ConnectionManager.ValidatePolicies(ConnectionEngine engine, Boolean hasChanged) at Devolutions.RemoteDesktopManager.Managers.ConnectionManager.LoadConnectionsFromDataSource(ConnectionEngine engine, Boolean hasChanged) at Devolutions.RemoteDesktopManager.Managers.ConnectionManager.LoadConnections(BaseConnectionDataSource dataSource)
And now it 'hangs' with "Migrating data content to version 1"
That gives me a good idea of what the problem is.
I'll look into it and keep you updated.
Jonathan Lafontaine
Hi,
I have news.
The module version 2022.1.0.8 should fix your issue.
Let me know if you still have issues using that version.
Regards
Jonathan Lafontaine
Hello,
Sorry for the late reaction.
I have tested it with 2022.1.1.0. and it works without any problems.
Thank you.