PowerShell connectivity methods to Devolutions Server

The following methods describe how to connect to Devolutions Server using PowerShell.

Method 1: Using Remote Desktop Manager Cmdlets

This new data source created with PowerShell will only exist in the user context it was created.

  1. Follow the instructions in Devolutions.PowerShell Core Module to properly install the module.
  2. Create a new Devolutions Server data source using an Application Key and Application Secret with the following script. This script should only be used once to avoid creating many new data sources. Replace the values of the four variables with your own information, then run the script.
$dsname = "DVLS PowerShell"
$dsurl = "https<area>://your_dvls_url"
$appkey = "your_appkey"
$appsecret = "your_appsecret"

$ds = New-RDMDataSource -DVLS -Name $dsname -Server $dsurl -ScriptingTenantID $appkey -ScriptingApplicationPassword $appsecret -SetDatasource -WarningAction SilentlyContinue
Set-RDMDataSource $ds
  1. To connect to the data source, use these lines in all your scripts.
$dsname = "DVLS PowerShell"
$ds = Get-RDMDataSource -Name $dsname
Set-RDMCurrentDataSource $ds

Method 2: Using Devolutions Server Cmdlets

  1. Follow the instructions in Devolutions.PowerShell Core Module to properly install the module.
  2. The script expects that your Devolutions Server credentials and URL be defined in environment variables. Since storing credentials in scripts is frowned upon, adapt a local file for running your own tests.
$env:DS_URL= ' http<area>://localhost/dvls
$env:DS_USER = '{your user here}'
$env:DS_PASSWORD = '{your password here}'
  1. The following sample script can be used to connect using an Application Key and Application Secret.
[string]$Username = $env:DS_USER
[string]$Password = $env:DS_PASSWORD
[string]$DVLSUrl = $env:DS_URL

[securestring]$SecPassword = ConvertTo-SecureString $Password -AsPlainText -Force
[pscredential]$Creds = New-Object System.Management.Automation.PSCredential ($Username, $SecPassword)

$Response = New-DSSession -Credential $Creds -BaseURI $DVLSUrl -AsApplication
  1. Once the script is completed and all tasks are fulfilled, close the session using the Close-DSSession cmdlet.
Close-DSSession | out-null
Write-Output ' '
Write-Output '...Done!'
Write-Output ' '
Give us Feedback