Before Open event script to pass value to Session.

Before Open event script to pass value to Session.

avatar

We have around 15k user home directories in a single older which crashes RDM and Windows Explorer when trying to open them. So thought I would get crafty and create a template that lets me use the Quick Connect to connect directly to the home directory path.

Started with a File Explorer session and using the Before Open event I run the following PoSh (Get-ADUser $QUICK_CONNECT$ -Properity HomeDirectory).HomeDirectory but I don't know how to pass that to the session's folder field.

Not sure if this is supported. Found all sorts of other things with the built in variables, but nothing that seems to pull the results of an executed script.

Didn't find anything about passing the output to a RDM system variable either. Did I just miss it in the forum or documenation?

All Comments (4)

avatar

Hello zabolyx,

I tried the following code in the file explorer entry (replacing $QUICK_CONNECT$ with an AD user) in Events - Before Open, and it opens to the correct folder, as expected.

$RDM.connection.FileExplorer.folder = (Get-ADUser $QUICK_CONNECT$ -Property HomeDirectory).HomeDirectory
$RDM.Save();


However, when used as a template, the $RDM.Save() does not save the entry properly before opening it, which instead results in the file explorer to open locally with the host specified as the $QUICK_CONNECT$ information. I will verify with the engineering team and get back to you.

Best regards,

Richard Boisvert

avatar

Well, I'm wondering if something like having the ability to pass the output directly through a value like $SCRIPT_OUTPUT$?

Modifying the template just to allow for a quick connect session seems like extra overhead on the database. I'm using the cloud db, so would I have to wait for that to update before opening?

avatar

Hello,

Would a custom variable that you change the value of be an acceptable workaround?

Also, the RDM.Save() does not actually save the entry, it modifies it just before opening the entry, but it stays local on the machine. Once you close the entry, the changes are discarded.

Best regard,

Richard Boisvert

avatar

Actually I can see the need for either, since it might be worth passing a value from a script to the arguments.

Doing a user lookup from the quick connect comes to mind.

Toss in the user name and a script runs and pulls the machine name from AD or SCCM and then launches PSExec to connect to that machine or Computer Management...

For that matter I could add a script to the RDP to even validate the quick connect value as a computer and if not look up the user and get the computer from there.... that would be a fun one for me to tackle.

I could also see it being useful for our NetApp configuration. Passing a path through Quick Connect could look up the DFS path and the allow me to connect to the correct NetApp cluster to manage.

I think I'll have plenty of ideas that I could do with a custom variable that could be used to pass data from the scripts. Might even be worth creating 2. Before and after scripts output values.