I am trying to figure out this Problem: When a user disconnects his/her RDS (on Windows Server 2012 R2) session in Office 1 and reconnects in Office 2, then still all the Printers relevant to Office 1 will be mapped.
First idea was to use the Task Scheduler to run a powershell script on trigger "Session reconnect" which Looks into the "clientname" variable and adds all relevant Printers to that Location after the reconnect.
Problems with this are that:
- to make the script run in the context of the specific user that just reconnected and not in some administrative context (tried solving this with run as Group DOMAIN\Users, but seems to work not as desired)
- the "clientname" Environment variable is not available when the PS script is run via Task Scheduler. It seems it is the only variable missing, but, bad enough, thats exactly the one i would Need here!
So, I am either looking for a way how the Scripting Problem could be solved properly or, even better, is there a known best practice how to handle Printer mapping when a user reconnects a terminal Server session from a different Location? Doesn't make much sense to have the paper appear in Offices/Locations far away ;-)
Thanks very much.