Using PowerShell to update RDP Session Host IP

Using PowerShell to update RDP Session Host IP

avatar

I'm accessing an AWS EC2 instance that has a dynamic IP.

I retrieve the current IP address and store it in $PublicIpAddress

$PublicIpAddress = ((Get-EC2Instance -InstanceID $InstanceId -Region $Region -ProfileName $ProfileName).Instances).PublicIpAddress

Then I'm retrieving the relevant RDM session in $session, updating $session.Host to = $PublicIpAddress, saving $session and calling Update-RDMUI

$session = Get-RDMSession -Name 'AWS Instance Name Here'

$session.Host = $PublicIpAddress

Set-RDMSession $session

Update-RDMUI

While this seems to work, I'm not seeing the new IP address until after I manually do a FILE > REFRESH via the RDM desktop client. Then the RDM session uses the newly acquired IP address. I thought that Update-RDMUI would have updated the session?

What am I missing? :(

Thanks.

All Comments (14)

avatar

Hello,

This should work normally without having to refresh RDM after running the PowerShell script.

What version or RDM are you using?

What data source type are you connected to?

If the data source is Devolutions Password Server, what version are you using?

Best regards,

Érica Poirier

avatar

Hi Erica,

We're running Remote Desktop Manager Enterprise Edition version 13.6.7.0 64-bit using a Devolutions Cloud online database.

Jamie

avatar

Hello Jamie,

I am still unable to reproduce your issue using the same RDM version and same data source.

Which PowerShell entry type are you using to modify the host?

Best regards,

Érica Poirier

avatar

I tried running the script from PowerShell ISE 64 and I also tried creating a Macro/Script/Tool entry of Script Type PowerShell (Local). The entry is saved with the Embedded Script option.

I've executed the Script by hand from the RDM client and also tried it set as a Before Connect Event on the RDP Session. The results in each case were similar. The script appears to complete without error. But if I execute the RDP Session it tries to connect to the old IP address. If I then manually refresh the RDM desktop... the IP is updated and the RDP session will work as expected.

I think I just got it to work.

If I right-click on my RDP session entry in the Navigation panel, scroll down to Macros.Scripts/Tools and select my PowerShell script from there, the script executes and I see the RDM interface update. The HOST IP address is updated with no further action required!

If I execute the script from the Macros/Scripts/Tools tab in the main window, the session doesn't update properly.

If the script executes as a Before Connect Event on the RDP Session the session doesn't update properly.

avatar

Hello,

Thank you very much for these detailed steps.

I only tried running the script using the context menu (right-click). I will test the other methods and will get back to you about it.

Best regards,

Érica Poirier

avatar

Hello,

So running the script from the Macros/Scripts/Tools tab work perfectly on my environment. After running the script, I click on the Overview tab and the Host information is up to date.

But no luck with the Before Connect event. RDM opens the RDP session before the script is completed so still connect on the old host. Unfortunately there is no Wait parameter for the Macro/Script/Tool option.

Are you using the following configuration for the Before Connect event?

Best regards,

Érica Poirier