We have some VDI users (zero client + Horizon 6) traveling between offices in different location and they want the default printer to be reset to a local printer, thus they won't accidentally sent a printing job to a remote location when they work in different location.
Although VM desktop has no idea where the user is actually located, Horizon View Broker does insert some ENV parameters into VM when user is connected.
From DOS cmd, run "SET" you will see something like this:
...
ViewClient_Broker_DNS_Name=xxx
ViewClient_Broker_DomainName=xxx
ViewClient_Broker_Remote_IP_Address=xxx.xxx.xxx.xxx
ViewClient_Broker_Tunneled=true
ViewClient_Broker_Tunnel_URL=https://xxxx.xxx.com:443
ViewClient_Broker_URL=https://xxx.xxx.com:443
...
"ViewClient_Broker_Remote_IP_Address" is the View Client device IP address (zero client, thin client or windows client), so, we can actually know the user logon location by reading this information.
So, here is the sample script (BAT) to read IP address and set default printer:
:: Read Horizon Client IP address
SET DeviceIP=%ViewClient_Broker_Remote_IP_Address:~0,7%
SET TorontoIP=10.34.1
SET MontrealIP=10.35.2
SET OttawaIP=10.36.3
:: Toronto Location
IF %DeviceIP% == %TorontoIP% wmic printer where name='\\\\server1\\printer1' call setdefaultprinter
GOTO END
:: Montreal Location
IF %DeviceIP% == %MontrealIP% wmic printer where name='\\\\server2\\printer2' call setdefaultprinter
GOTO END
:: Ottawa Location
IF %DeviceIP% == %OttawaIP% wmic printer where name='\\\\server3\\printer3' call setdefaultprinter
GOTO END
END:
For individual user, copy the script to user Start Up, or, you can use GPO to push it out globally.