In the documentation for the event: execute Powershell script before open, it says:
Using the $RDM.connection property, the script temporarily changes any of the session properties in the context of the session launch only. When the session is closed, the properties revert back to their original values.
This works fine.
However, is there a way to update the entry permanently using the 'before open' script?
I tried using $RDM.Save(), but the entry does not change.
Hello,
If you want to permanently update the entry in the Before Open Event, then you need to load the Devolutions.PowerShell module, fetch the entry, modify the permissions and then save it like we would normally do in a PowerShell script. The $RDM.Save like you experienced doesn't offer that possibility.
Import-Module Devolutions.PowerShell $session = Get-RDMSession -Name $NAME$ <update properties here> Set-RDMSession $session -Refresh
Let us know if you have further questions about this.
Best regards,
Érica Poirier
Thankyou for the quick reply.
I have tried your suggestion, if I use that code in a standalone powershell session then it works. However, when placed in the Before Open event, the entry is not changed.
This is my code - I hard coded the session_id to make sure there was no issue with variable substitution
If I run this in standalone powershell it works, but in the Event Before Open powershell script the value is not stored.
Import-Module Devolutions.PowerShell
$session = Get-RDMSession | where-Object {$_.id -eq "ca9a3250-a3f9-411f-97c8-63cba6a03fa5"}
$session.VMRC.VMid = "TEST"
Set-RDMSession $session -Refresh
I have noticed before that if I change an entry in the GUI whilst the entry is open, the changes are lost. I had always assumed that this was intended behaviour, but could you confirm this? Is that something to do with my data source? I am using Dropbox (Local).
Thanks
Hello,
In fact you are right. After having a discussion with an engineer, it's not possible to permanently update an entry using the Before Open event. It's the exact same behaviour when the entry is open. So it's not related to your data source.
Let us know if you have further questions about this.
Best regards,
Érica Poirier