powershell module error RemoteDesktopManager.PowerShellModule.PSOutputObject.PSConnection
we use ansible for deployment of new servers, i want to add newly deployed servers into remote desktop manager so i created a script for it
the first thing i do in my script is test if machine allready exists using:
$session = Get-RDMSession -Name $Name
write-host "Session $($session)"
and then check if $session is filled or not
This works great on windows it self but when doing the exact same code using ansible i get back in $session the line RemoteDesktopManager.PowerShellModule.PSOutputObject.PSConnection
I have no clue how to get the module to behave as normal as it does in windows itself
We have remote desktop manager version: 2025.1.37.0
and updated the powershell module to: devolutions.powershell.2025.1.5 using powershell 7.5
As database we use SQL connection
In ansible i make sure to also use the powershell 7 which i also query before running my logic so i know it is working under correct powershell version
complete ansible output:
ok: [IWF016] =>
msg:
changed: true
debug: []
error: []
failed: false
host_err: ''
host_out: |-
Dit script is uitgevoerd met PowerShell versie: 7.5.0
found folder PGB 2.0
found folder PGB 2.0\150. vCloud_Zandbak (DS03)
Session RemoteDesktopManager.PowerShellModule.PSOutputObject.PSConnection
RDP session 'ZFW0RDSA02 - rds_sessionhost' allready exists in Remote Desktop Manager.
information:
- message_data:
BackgroundColor: null
ForegroundColor: null
Message: 'Dit script is uitgevoerd met PowerShell versie: 7.5.0'
NoNewLine: false
source: Write-Host
tags:
- PSHOST
time_generated: '2025-05-20T14:25:52.1650811Z'
- message_data:
BackgroundColor: null
ForegroundColor: null
Message: found folder PGB 2.0
NoNewLine: false
source: Write-Host
tags:
- PSHOST
time_generated: '2025-05-20T14:25:54.4730332Z'
- message_data:
BackgroundColor: null
ForegroundColor: null
Message: |-
found folder PGB 2.0\150. vCloud_Zandbak (DS03)
NoNewLine: false
source: Write-Host
tags:
- PSHOST
time_generated: '2025-05-20T14:25:54.6426260Z'
- message_data:
BackgroundColor: null
ForegroundColor: null
Message: Session RemoteDesktopManager.PowerShellModule.PSOutputObject.PSConnection
NoNewLine: false
source: Write-Host
tags:
- PSHOST
time_generated: '2025-05-20T14:25:54.6831868Z'
- message_data:
BackgroundColor: null
ForegroundColor: null
Message: RDP session 'ZFW0RDSA02 - rds_sessionhost' allready exists in Remote Desktop Manager.
NoNewLine: false
source: Write-Host
tags:
- PSHOST
time_generated: '2025-05-20T14:25:54.8013274Z'
output:
- BuildLabel: null
Major: 7
Minor: 5
Patch: 0
PreReleaseLabel: null
- OsHardwareAbstractionLayer: 10.0.17763.4644
WindowsProductName: Windows Server 2019 Datacenter
WindowsVersion: '1809'
result: {}
verbose: []
warning: []
Hello info01,
This error might be related to how you use or call the variable $session.
Without the whole script, it's hard to pinpoint the issue.
You also mentioned that this script is working manually on Windows.
Could you tell me if Ansible is running on Windows or another OS?
Best regards,
Patrick Ouimet
bellow is the complete script, ansible runs in linux and is using winrm to connect to the windows server where the remote desktop manager client is installed.
I also updated to the new powershell module 2025.1.5, i noticed that the latest version was released 5 days ago, but the result is the same
- name: Execute RDM PowerShell commands using Powershell 7
ansible.windows.win_powershell:
executable: pwsh.exe
script: |
$PSVersionTable.PSVersion
Get-ComputerInfo | Select-Object WindowsProductName, WindowsVersion, OsHardwareAbstractionLayer
Write-Host "Dit script is uitgevoerd met PowerShell versie: $($PSVersionTable.PSVersion.ToString())"
# Load the RDM PowerShell module
Import-Module Devolutions.PowerShell # for powershell 7
function Check-RDMFolders {
param (
[parameter(Mandatory=$true, ValueFromPipeline=$true)] $folders
)
$lookupFolder = ""
$parentFolder = ""
foreach ($f in $folders.split('\')) {
# Try to find the folder under the current parent
$lookupFolder = $lookupFolder + $f
Try { $existingFolder = Get-RDMSession -GroupName $lookupFolder -ErrorAction Stop }
catch { $existingFolder = "" }
if ( $existingFolder ) {
# If found, update parentFolder
write-host "found folder $lookupFolder"
$parentFolder = $lookupFolder + "\"
} else {
# If not found, create the folder under the current parentFolder
write-host "create folder $lookupFolder"
if ($parentFolder) {
$newFolder = New-RDMSession -Name $f -Type Group -SetSession -Group $parentFolder.Substring(0,$parentFolder.Length-1) # Remove last '\' from parentFolder
} else {
$newFolder = New-RDMSession -Name $f -Type Group -SetSession
}
Set-RDMSession $newFolder -refresh
$parentFolder = $lookupFolder + "\"
}
$lookupFolder = $lookupFolder + "\"
}
}
$Name = "{{ serverNetbiosName }} - {{ target_role }}"
$hostName = "{{ target_host }}"
$folder = "{{ target_folder }}"
# Check if folder structure exist where items needs to be added, create if not exists
Check-RDMFolders -folders $folder
# Check if host exist, if not create it
$session = Get-RDMSession -Name $Name
write-host "Session $($session)"
if ($session.HostResolved) {
Write-Host "RDP session '$Name' allready exists in Remote Desktop Manager."
} else {
$session = New-RDMSession -Host $hostName -Type "RDPConfigured" -Name $Name -Group $folder -SetSession
# Update or refresh GUI so session is shown
Update-RDMUI
# Set connection properties
$session.OpenEmbedded = $true
Set-RDMSession -Session $session -Refresh
Write-Output "RDP session '$Name' added to Remote Desktop Manager."
}
register: rdm_script_result
Hello info01,
This is related to your write-host.
Can you change it to something like:
$session = Get-RDMSession -Name
$Name $sessionName = $session.name
write-host "Session: $sessionName"
Let us know if this fixes the entry name under your message.
Best regards,
Patrick Ouimet
This does not work either, the output is now the contents of variable $Name. So if i lookup host MyHost, and do:
$Name = "MyHost"
$session = Get-RDMSession -Name $Name
$sessionName = $session.name
write-host "Session: $sessionName"
Ouputs MyHost while the host does not exist on our RDM, if i search for hostname TestHost the output is also TestHost. Totally weird i must say
Again in plain powershell under windows it works as expected, but running it using the ansible job does not. ChatGpt suggested something that the module might not work if not run interactively, can that be the case that the module only operates under interactive prompt ?
Hello info01,
Suppose you are looking for the Host, $session.Host should be the correct variable.
From my perspective, the module works just fine.Name is the entry name and the .Host is the configured host in the entry.
Could you try running it without Ansible on Linux and tell me if it still works as well as it does on Windows?
Also, could you run it without the PS-Session on Linux?
Best regards,
Patrick Ouimet