How to use RemoteDesktopManager PowerShell module to get list of RDM entries

Resolved

How to use RemoteDesktopManager PowerShell module to get list of RDM entries

avatar

Hello, all!

I need to be able to pull a list of all RDP and SSH entries in our Remote Desktop Manager in a PowerShell script. Has anyone done this?
Some time was spent going through the documentation and found it a bit lacking on explanations and examples.

I tried, to no avail, using Get-RDMSession with some attributes but kept getting this error:
Get-RDMSession : Object reference not set to an instance of an object.

Looking through the Get-Help Get-RDMSession also didn't provide me any new information.

If anyone has accomplished this before, I would appreciate your insight if you're willing to share it! Many thanks,

--
Griff

--
Griffeth Barker
💻 Call/Chat on Microsoft Teams
📧 Send me an email
🔗 Connect on LinkedIn

All Comments (13)

avatar

Hello Griff,

Could you please run the following before the Get-RDMSession:

$ds = Get-RDMDataSource -Name 'name-of-datasource'
Set-RDMCurrentDataSource $ds


The Get-RDMSession should return all your entries in the last used vault after.

If it does not work, can you please specify what version of RDM you are currently using, as well as the result of Get-RDMInstance.

Best regards,

Richard Boisvert

avatar
Hello Griff,

Could you please run the following before the Get-RDMSession:

$ds = Get-RDMDataSource -Name 'name-of-datasource'
Set-RDMCurrentDataSource $ds

The Get-RDMSession should return all your entries in the last used vault after.

If it does not work, can you please specify what version of RDM you are currently using, as well as the result of Get-RDMInstance.

Best regards,
Richard Boisvert


Hi, Richard!

Thanks for your response. I ran the commands you requested and the first command provided the same error:

Get-RDMDataSource : Object reference not set to an instance of an object.
At line:1 char:1
+ Get-RDMDataSource -Name 'JEI-RDM'
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Get-RDMDataSource], NullReferenceException
    + FullyQualifiedErrorId : System.NullReferenceException,RemoteDesktopManager.PowerShellModule.GetRDMDatasourceCommand

RDM version I have installed is 2022.3.14.0 64-bit.

Thank you,

--
Griff

--
Griffeth Barker
💻 Call/Chat on Microsoft Teams
📧 Send me an email
🔗 Connect on LinkedIn

avatar

Hello Griff,

It seems the RDM PowerShell module is not installed, could you please run this command:

Install-Module -Name RemoteDesktopManager

You should be able to run the above cmdlet afterwards. For more information, please refer to the following - https://kb.devolutions.net/kb_rdmpowershellcore.html

Best regards,

Richard Boisvert

avatar
Hello Griff,

It seems the RDM PowerShell module is not installed, could you please run this command:
Install-Module -Name RemoteDesktopManagerYou should be able to run the above cmdlet afterwards. For more information, please refer to the following - https://kb.devolutions.net/kb_rdmpowershellcore.html

Best regards,


Hi, Richard,

Odd, the documentation I had read from Devolutions stated that if RDM is installed then you have the PS Module. My apologies. I did just try to install using the provided command and got this error:

PackageManagement\Install-Package : No match was found for the specified search criteria and module name 'RemoteDesktopManager'. Try Get-PSRepository to see all available registered module repositories.
At C:\Program Files (x86)\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:1809 char:21
+ ...          $null = PackageManagement\Install-Package @PSBoundParameters
+                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Exception
    + FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage

The output of the recommended command `Get-PSRepository` does reflect that the needed PSGallery repo is available and trusted:

Get-PSRepository

Name                      InstallationPolicy   SourceLocation
----                      ------------------   --------------
PSGallery                 Trusted              https://www.powershellgallery.com/api/v2

but it still didn't work. I then followed the manual installation instructions on the web link you provided. After manual install I restarted my PowerShell and was then able to successfully import the module and list the commands from it:

[12:49:23 PM] PS C:\Users\gbadmin\OneDrive - Jacobs Entertainment Inc\Repos\rsrrepo\jei-repo> Import-Module -Name RemoteDesktopManager -Force
[12:49:31 PM] PS C:\Users\gbadmin\OneDrive - Jacobs Entertainment Inc\Repos\rsrrepo\jei-repo> Get-Command -Module RemoteDesktopManager

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Alias           Add-RDMRoleVaultAccess                             2021.2.... RemoteDesktopManager
Alias           Add-RDMUserVaultAccess                             2021.2.... RemoteDesktopManager
Alias           Get-RDMCurrentVault                                2021.2.... RemoteDesktopManager
Alias           Get-RDMUserVaultSession                            2021.2.... RemoteDesktopManager
Alias           Get-RDMVault                                       2021.2.... RemoteDesktopManager
Alias           New-RDMVault                                       2021.2.... RemoteDesktopManager
Alias           Remove-RDMUserVaultAccess                          2021.2.... RemoteDesktopManager
Alias           Set-RDMDatasourceVault                             2021.2.... RemoteDesktopManager
Alias           Set-RDMUserVaultSession                            2021.2.... RemoteDesktopManager
Alias           Set-RDMVault                                       2021.2.... RemoteDesktopManager
Alias           Update-RDMVault                                    2021.2.... RemoteDesktopManager
Cmdlet          Add-RDMRoleRepositoryAccess                        2021.2.... RemoteDesktopManager
Cmdlet          Add-RDMRoleToUser                                  2021.2.... RemoteDesktopManager
Cmdlet          Add-RDMSessionAttachment                           2021.2.... RemoteDesktopManager
Cmdlet          Add-RDMUserRepositoryAccess                        2021.2.... RemoteDesktopManager
Cmdlet          Close-RDMSession                                   2021.2.... RemoteDesktopManager
Cmdlet          Copy-RDMSession                                    2021.2.... RemoteDesktopManager
Cmdlet          Export-RDMSession                                  2021.2.... RemoteDesktopManager
Cmdlet          Get-RDMCommand                                     2021.2.... RemoteDesktopManager
Cmdlet          Get-RDMCurrentDataSource                           2021.2.... RemoteDesktopManager
Cmdlet          Get-RDMCurrentRepository                           2021.2.... RemoteDesktopManager
Cmdlet          Get-RDMDataSource                                  2021.2.... RemoteDesktopManager
Cmdlet          Get-RDMDatasourceProperty                          2021.2.... RemoteDesktopManager
Cmdlet          Get-RDMInstance                                    2021.2.... RemoteDesktopManager
Cmdlet          Get-RDMLicense                                     2021.2.... RemoteDesktopManager
Cmdlet          Get-RDMOpenedSession                               2021.2.... RemoteDesktopManager
Cmdlet          Get-RDMPlaylistLocal                               2021.2.... RemoteDesktopManager
Cmdlet          Get-RDMPlaylistShared                              2021.2.... RemoteDesktopManager
Cmdlet          Get-RDMPowerShellOverride                          2021.2.... RemoteDesktopManager
Cmdlet          Get-RDMPrivateSession                              2021.2.... RemoteDesktopManager
Cmdlet          Get-RDMProcess                                     2021.2.... RemoteDesktopManager
Cmdlet          Get-RDMRegistrationInfo                            2021.2.... RemoteDesktopManager
Cmdlet          Get-RDMRepository                                  2021.2.... RemoteDesktopManager
Cmdlet          Get-RDMRole                                        2021.2.... RemoteDesktopManager
Cmdlet          Get-RDMRootSession                                 2021.2.... RemoteDesktopManager
Cmdlet          Get-RDMSecurityGroup                               2021.2.... RemoteDesktopManager
Cmdlet          Get-RDMSession                                     2021.2.... RemoteDesktopManager
Cmdlet          Get-RDMSessionAttachment                           2021.2.... RemoteDesktopManager
Cmdlet          Get-RDMSessionCredentials                          2021.2.... RemoteDesktopManager
Cmdlet          Get-RDMSessionDocumentStoredInDatabase             2021.2.... RemoteDesktopManager
Cmdlet          Get-RDMSessionDomain                               2021.2.... RemoteDesktopManager
Cmdlet          Get-RDMSessionPassword                             2021.2.... RemoteDesktopManager
Cmdlet          Get-RDMSessionProperty                             2021.2.... RemoteDesktopManager
Cmdlet          Get-RDMSessionStatus                               2021.2.... RemoteDesktopManager
Cmdlet          Get-RDMSessionUserName                             2021.2.... RemoteDesktopManager
Cmdlet          Get-RDMTemplate                                    2021.2.... RemoteDesktopManager
Cmdlet          Get-RDMUser                                        2021.2.... RemoteDesktopManager
Cmdlet          Get-RDMUserSpecificSettings                        2021.2.... RemoteDesktopManager
Cmdlet          Import-RDMSession                                  2021.2.... RemoteDesktopManager
Cmdlet          Invoke-RDMCreateDataSourceDatabase                 2021.2.... RemoteDesktopManager
Cmdlet          Invoke-RDMLoadFromInventorySession                 2021.2.... RemoteDesktopManager
Cmdlet          Invoke-RDMParentSession                            2021.2.... RemoteDesktopManager
Cmdlet          Invoke-RDMUnparentSession                          2021.2.... RemoteDesktopManager
Cmdlet          Invoke-RDMUpdateDataSourceDatabase                 2021.2.... RemoteDesktopManager
Cmdlet          New-RDMDataSource                                  2021.2.... RemoteDesktopManager
Cmdlet          New-RDMLicense                                     2021.2.... RemoteDesktopManager
Cmdlet          New-RDMLogComment                                  2021.2.... RemoteDesktopManager
Cmdlet          New-RDMPlaylistLocal                               2021.2.... RemoteDesktopManager
Cmdlet          New-RDMPlaylistShared                              2021.2.... RemoteDesktopManager
Cmdlet          New-RDMRandomPassword                              2021.2.... RemoteDesktopManager
Cmdlet          New-RDMRepository                                  2021.2.... RemoteDesktopManager
Cmdlet          New-RDMRole                                        2021.2.... RemoteDesktopManager
Cmdlet          New-RDMSecurityGroup                               2021.2.... RemoteDesktopManager
Cmdlet          New-RDMSession                                     2021.2.... RemoteDesktopManager
Cmdlet          New-RDMTemplate                                    2021.2.... RemoteDesktopManager
Cmdlet          New-RDMUser                                        2021.2.... RemoteDesktopManager
Cmdlet          Open-RDMQuickConnect                               2021.2.... RemoteDesktopManager
Cmdlet          Open-RDMSession                                    2021.2.... RemoteDesktopManager
Cmdlet          Open-RDMSyncSession                                2021.2.... RemoteDesktopManager
Cmdlet          Read-RDMSession                                    2021.2.... RemoteDesktopManager
Cmdlet          Remove-RDMDataSource                               2021.2.... RemoteDesktopManager
Cmdlet          Remove-RDMLicense                                  2021.2.... RemoteDesktopManager
Cmdlet          Remove-RDMRepository                               2021.2.... RemoteDesktopManager
Cmdlet          Remove-RDMRole                                     2021.2.... RemoteDesktopManager
Cmdlet          Remove-RDMRoleRepositoryAccess                     2021.2.... RemoteDesktopManager
Cmdlet          Remove-RDMRoleToUser                               2021.2.... RemoteDesktopManager
Cmdlet          Remove-RDMSecurityGroup                            2021.2.... RemoteDesktopManager
Cmdlet          Remove-RDMSession                                  2021.2.... RemoteDesktopManager
Cmdlet          Remove-RDMSessionAttachment                        2021.2.... RemoteDesktopManager
Cmdlet          Remove-RDMTemplate                                 2021.2.... RemoteDesktopManager
Cmdlet          Remove-RDMUser                                     2021.2.... RemoteDesktopManager
Cmdlet          Remove-RDMUserRepositoryAccess                     2021.2.... RemoteDesktopManager
Cmdlet          Remove-RDMUserSpecificSettings                     2021.2.... RemoteDesktopManager
Cmdlet          Rename-RDMGroup                                    2021.2.... RemoteDesktopManager
Cmdlet          Restart-RDMProcess                                 2021.2.... RemoteDesktopManager
Cmdlet          Set-RDMCurrentDataSource                           2021.2.... RemoteDesktopManager
Cmdlet          Set-RDMCurrentRepository                           2021.2.... RemoteDesktopManager
Cmdlet          Set-RDMDataSource                                  2021.2.... RemoteDesktopManager
Cmdlet          Set-RDMDatasourceMasterKey                         2021.2.... RemoteDesktopManager
Cmdlet          Set-RDMDatasourceProperty                          2021.2.... RemoteDesktopManager
Cmdlet          Set-RDMDatasourceRepository                        2021.2.... RemoteDesktopManager
Cmdlet          Set-RDMLicense                                     2021.2.... RemoteDesktopManager
Cmdlet          Set-RDMPersonalCredentials                         2021.2.... RemoteDesktopManager
Cmdlet          Set-RDMPlaylistLocal                               2021.2.... RemoteDesktopManager
Cmdlet          Set-RDMPlaylistShared                              2021.2.... RemoteDesktopManager
Cmdlet          Set-RDMPowerShellOverride                          2021.2.... RemoteDesktopManager
Cmdlet          Set-RDMPrivateSession                              2021.2.... RemoteDesktopManager
Cmdlet          Set-RDMRegistrationInfo                            2021.2.... RemoteDesktopManager
Cmdlet          Set-RDMRepository                                  2021.2.... RemoteDesktopManager
Cmdlet          Set-RDMRole                                        2021.2.... RemoteDesktopManager
Cmdlet          Set-RDMRoleGroupRights                             2021.2.... RemoteDesktopManager
Cmdlet          Set-RDMRoleProperty                                2021.2.... RemoteDesktopManager
Cmdlet          Set-RDMRootSession                                 2021.2.... RemoteDesktopManager
Cmdlet          Set-RDMSecurityGroup                               2021.2.... RemoteDesktopManager
Cmdlet          Set-RDMSecurityGroupProperty                       2021.2.... RemoteDesktopManager
Cmdlet          Set-RDMSession                                     2021.2.... RemoteDesktopManager
Cmdlet          Set-RDMSessionAttachment                           2021.2.... RemoteDesktopManager
Cmdlet          Set-RDMSessionCredentials                          2021.2.... RemoteDesktopManager
Cmdlet          Set-RDMSessionDocument                             2021.2.... RemoteDesktopManager
Cmdlet          Set-RDMSessionDomain                               2021.2.... RemoteDesktopManager
Cmdlet          Set-RDMSessionPassword                             2021.2.... RemoteDesktopManager
Cmdlet          Set-RDMSessionProperty                             2021.2.... RemoteDesktopManager
Cmdlet          Set-RDMSessionStatus                               2021.2.... RemoteDesktopManager
Cmdlet          Set-RDMSessionUsername                             2021.2.... RemoteDesktopManager
Cmdlet          Set-RDMSQLiteDatasourcePassword                    2021.2.... RemoteDesktopManager
Cmdlet          Set-RDMTemplate                                    2021.2.... RemoteDesktopManager
Cmdlet          Set-RDMUser                                        2021.2.... RemoteDesktopManager
Cmdlet          Set-RDMUserGroupRights                             2021.2.... RemoteDesktopManager
Cmdlet          Set-RDMUserProperty                                2021.2.... RemoteDesktopManager
Cmdlet          Set-RDMUserSecurity                                2021.2.... RemoteDesktopManager
Cmdlet          Set-RDMUserSpecificSettings                        2021.2.... RemoteDesktopManager
Cmdlet          Start-RDMInstance                                  2021.2.... RemoteDesktopManager
Cmdlet          Start-RDMProcess                                   2021.2.... RemoteDesktopManager
Cmdlet          Stop-RDMProcess                                    2021.2.... RemoteDesktopManager
Cmdlet          Update-RDMRepository                               2021.2.... RemoteDesktopManager
Cmdlet          Update-RDMSessionAttachment                        2021.2.... RemoteDesktopManager
Cmdlet          Update-RDMUI                                       2021.2.... RemoteDesktopManager

Then I re-ran the commands you provided me initially and now get this error message:

Get-RDMDataSource : Cannot validate argument on parameter 'Name'. The argument "JEI-RDM" does not belong to the set "Local Data Source" specified by the ValidateSet attribute. Supply an argument that is in the set and then try the command again.
At line:1 char:42
+ $RdmDatasource = Get-RDMDataSource -Name 'JEI-RDM'
    + CategoryInfo          : InvalidData: (:) [Get-RDMDataSource], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,RemoteDesktopManager.PowerShellModule.GetRDMDatasourceCommand

We are using an MSSQL datasource if that matters.

Thanks,

--
Griff

--
Griffeth Barker
💻 Call/Chat on Microsoft Teams
📧 Send me an email
🔗 Connect on LinkedIn

avatar

Hello Griff,

Sorry for the long delay, can you try to run :
Get-RDMInstance
and
Get-RDMPowershellOverride

To see if we're linked to the right configuration file?

You can also try to run Update-RDMUI before calling a
Get-RDMDataSource

Last thing, make sure the version (Both the Major.Minor) are matching with RDM and the PowerShell Module.

Thanks for keeping us posted.

Best regards,

Alex Belisle

avatar
Hello Griff,

Sorry for the long delay, can you try to run :
Get-RDMInstance
and
Get-RDMPowershellOverride

To see if we're linked to the right configuration file?

You can also try to run Update-RDMUI before calling a
Get-RDMDataSource

Last thing, make sure the version (Both the Major.Minor) are matching with RDM and the PowerShell Module.

Thanks for keeping us posted.

Best regards,


Hi, Alexandre!

Thank you for the reply. Running Get-RDMInstance returns this error:

WARNING: The type initializer for 'Client.ConnectorFactory' threw an exception.\n   at RemoteDesktopManager.ServiceInitializer.Initialize()
   at RemoteDesktopManager.PowerShellModule.BaseCommand.BeginProcessing()
Get-RDMInstance : Object reference not set to an instance of an object.
At line:1 char:1
+ Get-RDMInstance
+ ~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Get-RDMInstance], NullReferenceException
    + FullyQualifiedErrorId : System.NullReferenceException,RemoteDesktopManager.PowerShellModule.GetRDMInstance

Running Get-RDMPowerShellOverride returns this:

OptionFilePath RemoteDesktopManagerExecutablePath
-------------- ----------------------------------

Running Update-RDMUI returns this error:

Update-RDMUI : Object reference not set to an instance of an object.
At line:1 char:1
+ Update-RDMUI
+ ~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Update-RDMUI], NullReferenceException
    + FullyQualifiedErrorId : System.NullReferenceException,RemoteDesktopManager.PowerShellModule.UpdateRDMUICommand

It appears that the desktop client version is 2022.3.14.0 64-bit and the PowerShell module version that installed from the PSGallery (via instructions provided by Devolutions) is 2021.2.0.27. Which is weird because the package I downloaded and installed was 2022.3.1.0 (current version available). So I uninstalled it and reinstalled. It appears you have to use this command instead of the one provided in the documentation:

Install-Module -Name RemoteDesktopManager -RequiredVersion $version -Force

I'm now going to try the previously recommended commands and see if they work. I will provide an update momentarily.

Thank you!

--
Griffeth Barker
💻 Call/Chat on Microsoft Teams
📧 Send me an email
🔗 Connect on LinkedIn

avatar

Looks like no luck yet:

> $RdmDatasource = Get-RDMDataSource -Name 'JEI-RDM'
Set-RDMCurrentDataSource $RdmDatasource

Get-RDMDataSource : Object reference not set to an instance of an object.
At line:1 char:18
+ $RdmDatasource = Get-RDMDataSource -Name 'JEI-RDM'
+                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Get-RDMDataSource], NullReferenceException
    + FullyQualifiedErrorId : System.NullReferenceException,RemoteDesktopManager.PowerShellModule.GetRDMDatasourceCommand
 
WARNING: Data source not found

--
Griffeth Barker
💻 Call/Chat on Microsoft Teams
📧 Send me an email
🔗 Connect on LinkedIn

avatar

It appears even after removing and reinstalling the module version 2022.3.1.0, I get this:

Get-Module -Name RemoteDesktopManager | Select Name,Version

Name                 Version    
----                 -------
RemoteDesktopManager 2021.2.0.27

So I'm pretty confused.

--
Griffeth Barker
💻 Call/Chat on Microsoft Teams
📧 Send me an email
🔗 Connect on LinkedIn

avatar

Hello Griff,

Well, this explains why you cannot connect to your newer data source...
Now we have to figure out why the installation (Install-Module) doesn't use your latest installed PowerShell Module.

I understand you want to list your RDPs and SSHs, but we don't necessarily need PowerShell to achieve this.

What is it you're trying to do exactly?
What tools are you using? (VSCode, Windows PowerShell , RDM -> PowerShell (RDM CmdLet)) ?

Installing the PowerShell module will likely put the files in your Documents\PowerShell\Modules\RemodeDesktopManager folder. You might want to delete what's in there to start fresh.

Thanks for keeping me posted.

Best regards,

Alex Belisle

avatar

Thanks for your response.

Yes, indeed it appears so. Still haven't figured out why it keeps showing old version of the PS module despite complete uninstall and reinstall of RDM, the module, etc.

Installing the PowerShell module will likely put the files in your Documents\PowerShell\Modules\RemodeDesktopManager folder. You might want to delete what's in there to start fresh.

I will give this a shot, thanks for the idea.

What is it you're trying to do exactly?

As part of a maintenance script that runs on a schedule, need to be able to get a custom filtered list of session entries in RDM so I can cross reference them against our CMDB platform to ensure that all our nodes have entries in RDM.

What tools are you using? (VSCode, Windows PowerShell , RDM -> PowerShell (RDM CmdLet)) ?

The script is being written in VSCode using the default PowerShell environment. Once functional, it will be automatically run on a schedule by our PowerShell Universal server.

--
Griffeth Barker

--
Griffeth Barker
💻 Call/Chat on Microsoft Teams
📧 Send me an email
🔗 Connect on LinkedIn

avatar

Hello Griffeth,

Have you gotten a chance to clear the remaining installation of the RDM PowerShell module?

Is there anything else we can do?

Best regards,

Alex Belisle

avatar

Hi, Alexandre!

I uninstalled the RDM PowerShell module, removed the directory ~\Documents\Windows PowerShell\Modules\RemoteDesktopManager, then restarted my VSCode and installed the module again. After that, I was able to import the module and run commands as expected. It appears the issue here was that we use Microsoft OneDrive in our environment, which syncs the Documents folder between computers. I had to remove the aforementioned directory and wait for that to sync, then retry installation. Thank you for all of you and the Devolutions team's assistance on this over the past few months. It is appreciated! I would consider this thread resolved.

--
Griffeth Barker | IT Systems Administrator

--
Griffeth Barker
💻 Call/Chat on Microsoft Teams
📧 Send me an email
🔗 Connect on LinkedIn

avatar

Hello Griffeth

That's awesome news, thanks a lot for the feedback, glad we figured this out together!

Best regards,

Alex Belisle