Powershell remote sessions in RDM

Resolved

Powershell remote sessions in RDM

avatar
Arturas
Disabled

Good day,

I am using v14 of remote desktop manager.

I would like to run simple (Get-WmiObject Win32_logicaldisk) command on a server to check state of disk drives on server, is it possible to use PS RDM module to acomplish this?

I would prefer to open a session using admin credentials to server and then get the information. I saw an example of similar feature with an earlier version.


If such thing is possible, would you mind posting an example.

All Comments (81)

avatar

Hello,

You can create a PowerShell (Remote) Macro/Script/Tool entry type and then run it on the server you want to get the information.

Here are some methods to run the script.

The first one is to execute it using the RDM Agent. It is mandatory that the RDM Agent must be installed on the remote computer. And a connection must already be opened to this machine. Then you run the script using the Execute script via Agent feature.



Another method is to run the script from the Macros/Scripts/Tools panel. The remote computer must be available from your workstation to be able to run the script. And no need to have an open connection to that remote machine.



Best regards,

Érica Poirier

avatar

Thank you for suggestion, but these involve using a GUi to setup every single sever.

I have a very large amount of machines and i am not sure that i want to go one by one on each and do the clicks, then copy data i get and create report by hand.

The whole idea would i would like to go trough a select list of machines and capture the returned values in a variable that i can later use to construct a report automaticaly.

I see that you have "New-RDMSession -Type PowerShell/PowerShellRemoteConsole" commands, is there a way i coudl use those with specific credentials to achieve this ?

At the moment i am failing to open a powershell session, an example on how to do this would be great.

avatar

Hello,

It is possible to run a script that will connect on a set of remote machines that are existing in RDM to get the information.

You need to use the Get-RDMSession cmdlet to retrieve the list of the remote computers from RDM. Then, using this list, you can get the information remotely using the Get-WmiObject cmdlet. To connect on those remote using specific credentials available in RDM, you can use the Get-RDMSessionUsername and Get-RDMSessionPassword cmdlets.

Here is a sample script that could be use to get the list of the computers you want to connect to from RDM and get the main credential.You may have to adapt it to fit your environment.
* Get all RDP entries from RDM

$computers = Get-RDMSession | where {$_.ConnectionType -eq "RDPConfigured"}

* Get the main credential to connect on those machines
$credsession = Get-RDMSession -Name "MyAdminCredential"
$username = Get-RDMSessionUserName -Session $credsession
$passwd = Get-RDMSessionPassword -Session $credsession
$credential = New-Object System.Management.Automation.PSCredential($username, $passwd)

Here is a page that contains an example on how to use the Get-WMIObject cmdlet to get the information from a remote computer using specific credentials.
https://blogs.technet.microsoft.com/gary/2009/07/23/creating-a-ps-credential-from-a-clear-text-password-in-powershell/

Best regards,

Érica Poirier

avatar

This is great!

One small mistake though:
$computers = Get-RDMSession | where {$_.ConnectionType = "RDPConfigured"}

It should be:


$computers = Get-RDMSession | where {$_.ConnectionType -eq "RDPConfigured"}


I get this list, but how do i actually connect, the code you provide shows how to configure a credential file and all is great. But how to use it to connect to machine?

I have $credential object and a list of $computer:
$credential = New-Object System.Management.Automation.PSCredential($username, $passwd)



But how I can use those credentials to connect to actual machine from the list?

The WMI command does not work with error, even though this server has conenction type "RDPConfigured"
it shows error:
Get-WMIObject : The RPC server is unavailable


Code i have so far:


$credsession = Get-RDMSession -Name "A machine name"
$username = Get-RDMSessionUserName -Session $credsession
$password = "password" | ConvertTo-SecureString -asPlainText -Force

$credential = New-Object System.Management.Automation.PSCredential($username, $password)

Get-WMIObject win32_logicaldisk -ComputerName $credsession -Credential $credential

avatar

Hello,

Thank you for pointing out the mistake. Fixed!

The Get-WMIObject cmdlet will try to contact the remote computer specified with the -ComputerName switch.

In the provided commands, the $computers variable contains the list of remote machines. The $credsession contains the RDM credential entry object you want to use to connect on the remote computer, not the remote machine name.

So here what the script should be as it needs to loop across all computers.

* Get all RDP entries from RDM
$computers = Get-RDMSession | where {$_.ConnectionType -eq "RDPConfigured"}

* Get the main credential to connect on those machines
$credsession = Get-RDMSession -Name "MyAdminCredential"
$username = Get-RDMSessionUserName -Session $credsession
$passwd = Get-RDMSessionPassword -Session $credsession
$credential = New-Object System.Management.Automation.PSCredential($username, $passwd)

foreach ($computername in $computers)
{
$result = Get-WMIObject win32_logicaldisk -ComputerName $computername -Credential $credential
}


Then, in the foreach loop, you will have to save the content of the $result variable where you want (file, array, etc)

Best regards,

Érica Poirier

avatar

Thank you for suggestion! :)

I've tried suggested approach and it showed me an error, is there any other way i coudl open a connection, using your commandlets maybe?:


$result = Get-WMIObject win32_logicaldisk -ComputerName $computername -Credential $credential

$computername.ConnectionType
Get-WMIObject : The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)
At line:1 char:11
+ $result = Get-WMIObject win32_logicaldisk -ComputerName $computername ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Get-WmiObject], COMException
+ FullyQualifiedErrorId : GetWMICOMException,Microsoft.PowerShell.Commands.GetWmiObjectCommand

RDPConfigured

avatar

Hello,

The reason why you get this error is because maybe a firewall rule or some privileges are missing to open a connection to that remote machine through WMI. Here are few Microsoft articles that will provide some information about WMI Connection.
https://docs.microsoft.com/en-us/windows/desktop/WmiSdk/connecting-to-wmi-remotely-starting-with-vista
https://docs.microsoft.com/en-us/windows/desktop/WmiSdk/connecting-to-wmi-on-a-remote-computer

Best regards,

Érica Poirier

avatar

Erica,

So it seems there are no other way to connect trough RDM session to server?


I can run wmi and invoke-command on the test enviroment but production is a lot more secure.

I thought i could leverage RDM commandlets to connect to server that i can open RDM connections trough the application, without the need of changing the settings in remote server firewalls(which is a security risk), this is the main thing i am trying to achieve.

avatar

Hello,

You could use the Invoke-RDMLoadFromInventorySession to update the Information of each entry using the Load from Inventory and then browse through all your RDP entries to build the report. The Drives property can be accessed using $session.MetaInformation.Drives. Is it a good solution for what you want to achieve?




Best regards,

Érica Poirier

avatar
Hello, I have an enterprise version 2020.2.20.0 with an AD integrated MS SQL database each users has their own collections using different session credentials. I was trying to use a powershell similar to the one below that I can use to run a weekly Load inventory. I looks like the session credentials would have to be the same for all users in order to run this from the admin account, is that correct?

Thanks, Josh

Hello,

It is possible to run a script that will connect on a set of remote machines that are existing in RDM to get the information.

You need to use the Get-RDMSession cmdlet to retrieve the list of the remote computers from RDM. Then, using this list, you can get the information remotely using the Get-WmiObject cmdlet. To connect on those remote using specific credentials available in RDM, you can use the Get-RDMSessionUsername and Get-RDMSessionPassword cmdlets.

Here is a sample script that could be use to get the list of the computers you want to connect to from RDM and get the main credential.You may have to adapt it to fit your environment.
* Get all RDP entries from RDM

$computers = Get-RDMSession | where {$_.ConnectionType -eq "RDPConfigured"}

* Get the main credential to connect on those machines
$credsession = Get-RDMSession -Name "MyAdminCredential"
$username = Get-RDMSessionUserName -Session $credsession
$passwd = Get-RDMSessionPassword -Session $credsession
$credential = New-Object System.Management.Automation.PSCredential($username, $passwd)

Here is a page that contains an example on how to use the Get-WMIObject cmdlet to get the information from a remote computer using specific credentials.
https://blogs.technet.microsoft.com/gary/2009/07/23/creating-a-ps-credential-from-a-clear-text-password-in-powershell/

Best regards,
avatar

Hello Josh,

In the sample script that was provided, it uses the credentials contained in an entry to build a credential variable that is then used to connect to the different machines. As long as the credentials have the appropriate rights to connect to the remote machines, any user should be able to use them.

Best regards,

Richard Boisvert

avatar

Ok, Sor I get a Session: Error Getting Bios Information below is what I am using. I am running the script from the RDM admin account and each users folder is pretty much locked down to only that user so that their personal credentials can't be used by another team member to log into a machine. The credentials I am using should have RDP access to pretty much every server minus a couple one off's.

$Sessions = Get-RDMSession | where {$_.ConnectionType -eq "RDPConfigured"}

# Get the main credential to connect on those machines
$credsession = Get-RDMSession -Name "mycredential"
$username = Get-RDMSessionUserName -Session $credsession
$passwd = Get-RDMSessionPassword -Session $credsession
$credential = New-Object System.Management.Automation.PSCredential($username, $passwd)

foreach ($Session in $Sessions)

{

Invoke-RDMLoadFromInventorySession $session -Credential $credential

Set-RDMSession $session -Refresh

}

Update-RDMUI

avatar

Hello Josh,

Depending on how the credentials are configured in the RDP entry, you could bypass the credential part of the script and use the credential configured in the RDP directly. As a test, under the property of the RDP entry - Asset, could you click on the button Load from Inventory. This is what the cmdlet is calling, but it will give you more information if there are errors.

forum image

As my colleague mentioned in a previous post, it is possible your firewall or permissions are missing, you can refer to this documentation
https://docs.microsoft.com/en-us/windows/desktop/WmiSdk/connecting-to-wmi-remotely-starting-with-vista
https://docs.microsoft.com/en-us/windows/desktop/WmiSdk/connecting-to-wmi-on-a-remote-computer

The simplified script I used, utilizing the credentials configured in the RDP entry, that populates the Asset tab:

$Sessions = Get-RDMSession | where {$_.ConnectionType -eq "RDPConfigured"}
foreach ($Session in $Sessions)
{
  Invoke-RDMLoadFromInventorySession $session 
  Set-RDMSession $session -Refresh
}
Update-RDMUI


Best regards,

Richard Boisvert

avatar

Hi
i have a Folder with some RDP Servers in it. Now i want to get the uptime from all sessions in this folder. How can i do that?
this code doesnt work:

$session = Get-RDMSession -Folder "ServersUptime\RDP"
foreach ($Session in $Sessions)
{
Get-WmiObject -Class Win32_OperatingSystem | select @{   n = "LastBootUpTime";  e = { $_.ConvertToDateTime($_.LastBootUpTime) }   }
}


as result i get the uptime from my local machine.

avatar

Hi,

If you want Get-WmiObject to fetch the info on a remote server, you have to specify the computer name or ip.
Get-WmiObject -Class Win32_OperatingSystem -ComputerName $Session.Host

Keep in mind, the user your are currently logged with needs to have access to the remove server for this to work.
If it's not the case, you'll have to provide a user with sufficient access rights.

Regards

Jonathan Lafontaine

avatar

-ComputerName $Session.Host was the right hint.
but now i got another problem witht $session = Get-RDMSession -Folder "ServersUptime\RDP"
it looks like Get-RDMSession is not picking the right folder. it picks every session from my RDM.

avatar

-Folder isn't a valid parameter for command Get-RDMSession but -GroupName does almost the same thing.
Because of the way RDM stores an entry's group info, they will appear in the list returned by Get-RDMSession.
You can filter out the group using its connection type however like so

$Sessions = Get-RDMSession -GroupName 'ServersUptime\RDP' | Where { $_.ConnectionType -ne "Group" }


If you want to include sub folders, you can add -IncludeSubFolders to Get-RDMSession.

Jonathan Lafontaine

avatar

another working hint. thank you.
and the next problem..

Get-WmiObject : Access Denied

if i try it in my powershell console it works.
this is what i use in my powershell console:

$cred = Get-Credential
Invoke-Command -ComputerName FQDNOfMyServer -UseSSL -ScriptBlock {Get-WmiObject -Class Win32_OperatingSystem | select @{   n = "LastBootUpTime";   e = { $_.ConvertToDateTime($_.LastBootUpTime) }   } } -Credential $cred
avatar

Does it still work if you merge the 2 approaches?

$Sessions = Get-RDMSession -GroupName 'ServersUptime\RDP' | Where { $_.ConnectionType -ne "Group" }
foreach ($Session in $Sessions)
{
    $cred = Get-Credential
    Invoke-Command -ComputerName $Session.Host -UseSSL -ScriptBlock {Get-WmiObject -Class Win32_OperatingSystem | select @{   n = "LastBootUpTime";   e = { $_.ConvertToDateTime($_.LastBootUpTime) }   } } -Credential $cred
}

Jonathan Lafontaine

avatar

yes it work! but why? the credentials are the same

avatar

I'm in not way, shape or form an expert in regard to Get-WmiObject so your guess is as good as mine.
One theory could be that when accessing a remote computer you have to provide credentials explicitly.

Jonathan Lafontaine

avatar

I found out that it has nothing to do with Get-WmiObject but it doesn't work with any command

some posts above there is an example how to get the credentials from the RDM Vault. But i dont understand how to implement this in the script.

# Get the main credential to connect on those machines
$credsession = Get-RDMSession -Name "mycredential"
$username = Get-RDMSessionUserName -Session $credsession 
$passwd = Get-RDMSessionPassword -Session $credsession 
$credential = New-Object System.Management.Automation.PSCredential($username, $passwd)
avatar

It's hard to know for sure without your script but based on what we have exchanged so far, it might look somewhat like this.

$Sessions = Get-RDMSession -GroupName 'ServersUptime\RDP' | Where { $_.ConnectionType -ne "Group" }
foreach ($Session in $Sessions)
{
    $username = Get-RDMSessionUserName -Session $Session 
    $passwd = Get-RDMSessionPassword -Session $Session 
    $credential = New-Object System.Management.Automation.PSCredential($username, $passwd)
    Invoke-Command -ComputerName $Session.Host -UseSSL -ScriptBlock {Get-WmiObject -Class Win32_OperatingSystem | select @{   n = "LastBootUpTime";   e = { $_.ConvertToDateTime($_.LastBootUpTime) }   } } -Credential $credential
}

Jonathan Lafontaine

avatar

we got it, now it works!
for testing purposes i am using only your script.
it was the right password but the wrong username format. cause i was trying to login on domain server i had to change the username format to domain\userforum image

Thanks Jonathan for your awesome help. you are great.

avatar

My pleasure, glad it works!

Jonathan Lafontaine

avatar

I still have one
for my rdp sessions i have configured vpn to connect automaticly if i doubleclick on the session.
how can i initiate the vpn connection in the script above?

avatar

any Idea?

avatar

This one is trickier.

Our module is a "compiled once, run everywhere" type of software. Because of that and the way our code base handles launching sessions we have to delegate those operations to RDM.

One way you might be able to do it would be to check if the rdp session has a vpn attached, fetch the vpn entry, launch it (which will call RDM), do your wmi call and finally close the vpn session if needed.

It could look somewhat like this (assuming your vpn is a link to an existing vpn entry)
You'll need RDM opened with the same data source configured for this to work.

$Sessions = Get-RDMSession -GroupName 'ServersUptime\RDP' | Where { $_.ConnectionType -ne "Group" }
foreach ($Session in $Sessions)
{
    if(![string]::IsNullOrEmpty($s.VPN.ExistingSessionID))
    {
        Open-RDMSession -ID $s.VPN.ExistingSessionID
    }
    $username = Get-RDMSessionUserName -Session $Session 
    $passwd = Get-RDMSessionPassword -Session $Session 
    $credential = New-Object System.Management.Automation.PSCredential($username, $passwd)
    Invoke-Command -ComputerName $Session.Host -UseSSL -ScriptBlock {Get-WmiObject -Class Win32_OperatingSystem | select @{   n = "LastBootUpTime";   e = { $_.ConvertToDateTime($_.LastBootUpTime) }   } } -Credential $credential
	if(![string]::IsNullOrEmpty($s.VPN.ExistingSessionID))
	{
  		Close-RDMSession -ID $s.VPN.ExistingSessionID -Force
	}
}

Jonathan Lafontaine

avatar

its not working.. its just dont open the vpn conenction without error message
the rdp session has a vpn attached and if i doubleclick it the vpn connection opens up.

avatar

What is the error message and what application outputs it?

Jonathan Lafontaine

avatar

there is no error message

avatar

Sorry, I misread.
So Open-RDMSession -ID $s.VPN.ExistingSessionID is not doing anything, is that right?

Jonathan Lafontaine

avatar

thats right

avatar

What version of RDM are your running?

Jonathan Lafontaine

avatar

I am using Version 2022.3.31.0 64-bit

avatar

I did an update today to Version 2022.3.32.0 64-bit but still no luck.

avatar

Are you using PS7 by any chance?
One thing we found recently is a compatibility issue between PS7 and RDM when it comes to inter process communication.

If you are using PS7, could you give PS5.1 a go?
If that was if, we have a fix on the way. Otherwise, we'll keep digging.

Jonathan Lafontaine

avatar

I am using PS5.1 and i am still digging.

i tried this short one

$Sessions = Get-RDMSession -GroupName 'ServersUptime\RDP' | Where { $_.ConnectionType -ne "Group" }
foreach ($Session in $Sessions)
{
     Open-RDMSession -ID $s.VPN.ExistingSessionID
}


and got an error message

Open-RDMSession : Cannot bind parameter "ID". The value "" cannot be in the type "System.Guid"
be converted. Error: "Unknown Guid format."  


maybe it helps.

avatar

Looks like some of your sessions don't have a vpn linked leading to some ExistingSessionID being an empty string.

if(![string]::IsNullOrEmpty($s.VPN.ExistingSessionID))
{
    Open-RDMSession -ID $s.VPN.ExistingSessionID
}


That should execute Open-RDMSession only when there's something in ExistingSessionID.

Jonathan Lafontaine

avatar

in my test session under ServersUptime\RDP, a fixed VPN connection is linked, it is not an inherited one. The VPN connection is also established as soon as I doubleclick the session. So why is the ExistingSessionID empty?

avatar

Looks like I mislead you with ExistingSessionID.

When a VPN is linked, VPNLinkWindowsID should have the right ID.
So the script should actually look like

$Sessions = Get-RDMSession -GroupName 'ServersUptime\RDP' | Where { $_.ConnectionType -ne "Group" }
foreach ($Session in $Sessions)
{
    if(![string]::IsNullOrEmpty($s.VPN.VPNLinkWindowsID))
    {
        Open-RDMSession -ID $s.VPN.VPNLinkWindowsID
    }
    $username = Get-RDMSessionUserName -Session $Session 
    $passwd = Get-RDMSessionPassword -Session $Session 
    $credential = New-Object System.Management.Automation.PSCredential($username, $passwd)
    Invoke-Command -ComputerName $Session.Host -UseSSL -ScriptBlock {Get-WmiObject -Class Win32_OperatingSystem | select @{   n = "LastBootUpTime";   e = { $_.ConvertToDateTime($_.LastBootUpTime) }   } } -Credential $credential
	if(![string]::IsNullOrEmpty($s.VPN.ExistingSessionID))
	{
  		Close-RDMSession -ID $s.VPN.VPNLinkWindowsID -Force
	}
}


Let me know if this works better (or at all).

Jonathan Lafontaine

avatar

looks like VPNLinkWindowsID is also the wrong one

$Sessions = Get-RDMSession -GroupName 'ServersUptime\RDP' | Where { $_.ConnectionType -ne "Group" }
foreach ($Session in $Sessions) { Open-RDMSession -ID $s.VPN.VPNLinkWindowsID  }

error:
Open-RDMSession : The argument cannot be bound to the "ID" parameter because it is NULL.

avatar

If you go in RDM, right click on a session you know has a linked vpn entry and select Clipboard -> Copy and then Preview in the dialog, you should be able to see which field holds the link id.

Jonathan Lafontaine

avatar

i cant find in the Preview any ID
there is a VPN section that looks like this

<VPN>
      <AddOn>
        <AddOnVersion>2022.3.16.0</AddOnVersion>
          <Properties>o238975bf92x5r3nß98453b/(%&$/CVR%(c6)/%"3b7e4ß23bqcrxn3ry8b2nJ&&&&523479eBX§(ER="§BCNRX=Q)§(RZMY§)R=)§&R/§XBRTN§$(TRYQ$ZMERQ?&%$§WSDFg76542!Q"WER%/T&/()Z=)NE?R$)==</Properties>
        </AddOn>
        <Application>AddOn</Application>
      <ApplicationSubType>8ef45e41-d957-43a9-9b12-07eb6c07665f</ApplicationSubType>
      <AutoClose>false</AutoClose>
      <CloseMode>Manually</CloseMode>
      <EnableAutoDetectIsOnlineVPN>False</EnableAutoDetectIsOnlineVPN>
      <Mode>ConnectPingHost</Mode>
    </VPN>
avatar

What VPN type are you connecting to? Is it an addon?

Jonathan Lafontaine

avatar

I use thegreenbow ipsec vpn client addon

avatar

Oh, I see what the problem is.
Your VPN session is defined directly in your RDP entry.

With this configuration, PowerShell won't be able to ask RDM to start your VPN without also starting a RDP session.
Assuming an opened RDP session to the host won't prevent Get-WmiObject from working, the script could then be

$Sessions = Get-RDMSession -GroupName 'ServersUptime\RDP' | Where { $_.ConnectionType -ne "Group" }
foreach ($Session in $Sessions)
{
    Open-RDMSession -ID $Session.ID

    $username = Get-RDMSessionUserName -Session $Session 
    $passwd = Get-RDMSessionPassword -Session $Session 
    $credential = New-Object System.Management.Automation.PSCredential($username, $passwd)
    Invoke-Command -ComputerName $Session.Host -UseSSL -ScriptBlock {Get-WmiObject -Class Win32_OperatingSystem | select @{   n = "LastBootUpTime";   e = { $_.ConvertToDateTime($_.LastBootUpTime) }   } } -Credential $credential
	
    Close-RDMSession -ID $Session.ID -Force
}


Alternatively, you could have your VPN in a separate entry and link your vpn in your RDP settings.
Then the script you've been using would work.

Jonathan Lafontaine

avatar

Yes now it works but its a litlle bit laggy.
what does that mean "Alternatively, you could have your VPN in a separate entry and link your vpn in your RDP settings" ?

avatar

If you add a new Green Bow VPN entry to your data source (right click on root -> New Entry -> VPN -> green bow) you could then link it your RDP entry instead.

With the new vpn entry created, right click on your RDP entry -> VPN/SSH/Gateway).
In the Type dropbox, select VPN Link.
In the settings (VPN Link) tab, you can then select your new green bow vpn entry.

If you have multiple entries using that vpn, repeat as needed.

Only launching the vpn session should be a bit faster than starting a full rdp session.

Let me know if this isn't clear.

Jonathan Lafontaine

avatar

I have add a VPN entry to my data source (right click on root -> New Entry -> VPN -> green bow)
then i link it to my test RDP entry in "ServersUptime\RDP"
but i dont understand "Only launching the vpn session should be a bit faster than starting a full rdp session." because the script still launchs my rdp test sesssion after it starts the vpn session.

avatar

If the VPN is a linked entry, we can get the ID from the RDP entry and tell RDM to launch the vpn instead.
When the vpn is embedded in the RDP entry, the only way is to start the RDP session, which is slower.

Jonathan Lafontaine

avatar

ok but the script doesent launch only the vpn. it still start the rdp sessions after it starts the vpn.

avatar

Hello,

I'm sorry to jump in this thread.

Have you tried the following in your script? This method will only open the VPN entry SonicWall that is linked in the RDP entry. It's not a GreenBow VPN but it's the same behaviour. Once the VPN connection is established, I can add in my script the command to open the RDP entry.

forum image

Is using this method helps to improve the performance to open the RDP entry or is it still slow?

Best regards,

Érica Poirier

avatar

I have adjusted the settings to fit my needs

$rdp = Get-RDMSession -Name "TestRDP"
$vpnID = $rdp.VPN.ExistingSessionID
Open-RDMSession -ID $vpnID


but i get an error message

Open-RDMSession: Cannot convert 'System.Object[]' to the type 'System.Guid' required by parameter 'ID'. Specified method is not supported.
avatar

Hello,

That's quite strange. The $rdp.VPN.ExistingSessionID field should contain only one session ID, not an array of objects.

Could you please verify what you get from the $rdp.VPN.ExistingSessionID property?

Could you please share some screen captures of your RDP's VPN configuration?

Best regards,

Érica Poirier

avatar

the $rdp.VPN.ExistingSessionID is empty
forum image


My RDP VPN configuration
forum image

forum image

avatar

Hello,

Thank you for the information.

According to your configuration, the VPN ID is located in the VPNLinkWindowsID property. Is it working if you use this property instead of VPNExisitngSessionID property in your script?

Best regards,

Érica Poirier

avatar

another error

forum image
maybe because the ID appears three times. but why 3 times?

avatar

Hello,

It's indeed quite strange. What RDM version are you using?

Could you please try to empty that property in PowerShell, save the session and then set it back on the RDM UI to see if it will contain only one ID?

$rdp.VPN.VPNLinkWindowsID = ""
Set-RDMSession $rdp -Refresh

Let me know if that helps.

Best regards,

Érica Poirier

avatar

it looks like the script can't find VPNLinkWindowsID it when it try to empty it
and then it appears again three times

Die Eigenschaft "VPNLinkWindowsID" wurde für dieses Objekt nicht gefunden. Vergewissern Sie sich, dass die Eigenschaft 
vorhanden ist und festgelegt werden kann.
In C:\temp\test.ps1:6 Zeichen:1
+ $rdp.VPN.VPNLinkWindowsID = ""
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : PropertyAssignmentException

4451176d-bb2b-4cfe-99d4-f168ae403e1a
4451176d-bb2b-4cfe-99d4-f168ae403e1a
4451176d-bb2b-4cfe-99d4-f168ae403e1a
Open-RDMSession : "System.Object[]" kann nicht in den Typ "System.Guid" konvertiert werden, der für den Parameter "ID" 
erforderlich ist. Die angegebene Methode wird nicht unterstützt.
In C:\temp\test.ps1:10 Zeichen:21
+ Open-RDMSession -ID $vpnID
+                     ~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Open-RDMSession], ParameterBindingException
    + FullyQualifiedErrorId : CannotConvertArgument,RemoteDesktopManager.PowerShellModule.OpenRDMSessionCommand
avatar

Hello,

Thank you for your feedback.

I think it would be easier to troubleshoot this problem in a remote session. Please send an email to service@devolutions.net and we will send you a link to book a support session. Ensure to add a reference to this forum's thread in your message.

Best regards,

Érica Poirier

avatar

I have found the reason why it appears three times, this is because the rdp session is linked 3 times.
if i remove 2 of the linked session then it appears only once as VPNLinkWindowsID and the script opens only the vpn session whitout the rdp session.
Unfortunately the linked sessions cannot be removed for various reasons so there must be a way to get it work with the linked sessions.

avatar

Worst case, take the first one, $rdp.VPN.VPNLinkWindowsID[0]

Jonathan Lafontaine

avatar

the [0] ist the first number form the ID in $rdp.VPN.VPNLinkWindowsID[0] so if the ID is 4451176d-bb2b-4cfe-99d4-f168ae403e1a then the result of $rdp.VPN.VPNLinkWindowsID[0] is 4
i tried [14] and the result is "c"

avatar

You tested that after removing the 2 other links?

Jonathan Lafontaine

avatar

i have tested with links and without links. both scenarios have the same result

avatar

Hello,

I think it would be easier to troubleshoot this in a support session.

Have you received my reply in ticket 00022098 that contains the link for you to book the session?

Best regards,

Érica Poirier

avatar

Hello Érica
i need to roll this up again.
After your remote help the script worked well.
But since the last update of RDM the script doesent work anymore. It gets stuck after the vpn opens. Its just wont go further. There is also no error message.

avatar

Hi,

Did you update to Devolutions.PowerShell but still using RDM 2022.3?
If so, the communication channel between the two is not compatible, unfortunately.

The RemoteDesktopManager PS module is still available and compatible with RDM 2022.3
Devolutions.PowerShell is the way forward but will required RDM 2023.1 as well.

Jonathan Lafontaine

avatar

I have updated today the RDM to version 2023.1.14.0 64-bit an Powershell to Version 7.3.3 but it remains the same behavior.
if i start the script it hangs at Remote Desktop Manager [Sessions are loaded from data source RDM SQL]

Version              Name                                Repository           Description
-------              ----                                ----------           -----------
2023.1.0.2           Devolutions.PowerShell              PSGallery            The Devolutions.PowerS…
avatar

what else can i check to get things work?

avatar

Can I send you a beta version of the module with a potential fix?

Jonathan Lafontaine

avatar

i have send you an email

avatar

Hello,

Just to confirm, we sent you the beta version link earlier today, did you receive it?

Best regards,

Richard Boisvert

avatar

hello
yes i received the link and my script works again with the beta version.


regards

avatar

Hello Bonny,

Great to hear! I notified Jonathan.

Best regards,

Richard Boisvert

avatar

Hi Bonny,

Glad this version works.
The next version of RDM will once again break compatibility with the IPC process of PowerShell.
That means the PS module version prior to the 2023.1.0.4 release won't be compatible with the new RDM release.

If you don't update RDM, you can keep that version of module, the only difference with the released module if the ipc fix.
To avoid manually loading the module everytime, you can overwrite the module installed by PS.

Otherwise, you can upgrade to 2023.1.0.4 and the new version of RDM once it's available.

Regards

Jonathan Lafontaine

avatar

Hello again

again the script doesent work anymore. I dont know if its the update of rdm or powershell7 .
The error message is: Cannot bind parameter 'ID'. Cannot convert value "" to type "System.Guid". Error: "Unrecognized Guid format."

RDM Version 2023.1.29.0 64-bit
PS7 Version 7.4.3

Regards

avatar

Hello Bonny,

It look like a Get-RDMSession is not returning a proper value, since the ID of the entry is empty.

Since you are using RDM 2023.1, could you please confirm - with Get-RDMInstance - that you are running the module version 2023.1.0.10 ?
If note, please execute the following and then restart PowerShell : Update-Module -Name Devolutions.PowerShell -RequiredVersion 2023.1.0.10

If you still receive an error, could you provide use with the script and the complete error so we know what line is returning it?

Best regards,

Richard Boisvert

avatar

Hello
I had to update the module with Update-Module -Name Devolutions.PowerShell -RequiredVersion 2023.1.0.10
thx Richard

Regards

avatar

Hello Bonny,

Glad to see updating the module fixed the issue. Once you upgrade to 2023.2, you will need to upgrade the module to the latest version:
Update-Module -Name Devolutions.PowerShell

Best regards,

Richard Boisvert