PowerShell script

avatar

Hi,
Im one the 2020.2.16.0 version
i found a PowerShell script on your forum:

Import-Module 'C:\Program Files (x86)\Devolutions\Remote Desktop Manager\RemoteDesktopManager.PowerShellModule.psd1'



$ds = Get-RDMDataSource -Name "S**********"

Set-RDMCurrentDataSource $ds



$sessions = Get-RDMSession | where {$_.ConnectionType -eq "VNC"}



foreach ($session in $sessions)

{

Invoke-RDMLoadFromInventorySession $session
Set-RDMSession $session -Refresh


but when i launch it i get this error :

Get-RDMSession : Connection not found.
At line:1 char:13
+ $sessions = Get-RDMSession | where {$_.ConnectionType -eq "VNC"}
+ ~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Get-RDMSession], Exception
+ FullyQualifiedErrorId : 0,RemoteDesktopManager.PowerShellModule.GetRDMSessionCommand

I tried a execution line by line and i found that this command never work "Get-RDMSession"
Can you help me ?
BP

All Comments (2)

avatar

Hello,

It seems that the Get-RDMSession cannot found any entry in your data source that has the name VNC. Is that possible?

Best regards,

Érica Poirier

avatar

Hi,

Sorry for the late response. It's working now but i get the 'error during the bios information obtention' ('im in french version idk the real expression of this error)
But when i'm using the button load form inventory in the property section it's work perfectly.
Here my script

Import-Module "${env:ProgramFiles(x86)}\Devolutions\Remote Desktop Manager\RemoteDesktopManager.PowerShellModule.psd1"


$grp = '****************************\POSTES DE TRAVAIL'
$s = Get-RDMSession -GroupName $grp


foreach ($a in $s) {


    if ($s.ConnectionType -eq 'VNC' -or $s.ConnectionType -eq 'RDPConfigured') {
        $psw = Get-RDMSessionPassword -ID $a.tools.CredentialConnectionID -AsPlainText
        $usr = Get-RDMSessionUserName -ID $a.tools.CredentialConnectionID
        
        $Password = ConvertTo-SecureString $psw -AsPlainText -Force
        $credential = New-Object System.Management.Automation.PSCredential $usr, $Password
        $a.Name
        Invoke-RDMLoadFromInventorySession $a -Credential $credential
        Set-RDMSession $a -Refresh
        Update-RDMUI


    }


}


Connection ErrorMessages Success
---------- ------------- -------
RemoteDesktopManager.PowerShellModule.PSOutputObject.PSConnection {Session: Erreur lors de l’obtention des informations de Bios.} True

Thanks for your help !

Best Regards.
BP