Automatically Switch App Volumes Managers in Multi-Site Deployment

Typically in a multi-site VDI scenario, you would have a global load balancer URL that would resolve to the App Volumes VIP in the local datacenter, preventing you from having to crack open the golden image each time you update your pools on each side. Sometimes having a global URL that only resolves to the datacenter VIP is not possible for various reasons. In order to get around this, we can script setting the App Volumes Agent registry keys in a simple batch file that is kept in the image. We’ll put it in C:\scripts\ChangeAppVolMan.bat:

@echo off
SET log=C:\scripts\AppVolSwitch.log
SET man1=manager1.fqdn
echo %date% %time% Running script... setting regkeys... >> %log%
REG ADD HKLM\SOFTWARE\WOW6432Node\CloudVolumes\Agent /v Manager_Address /t REG_SZ /d %man1% /f 1>> %log% 2>>&1
REG ADD HKLM\SYSTEM\CurrentControlSet\Services\svservice /v Manager1 /t REG_SZ /d %man1%:443 /f 1>> %log% 2>>&1
echo %date% %time% Stopping svservice... >> %log%
net stop svservice 1>> %log% 2>>&1
echo %date% %time% Starting svservice... >> %log%
net start svservice 1>> %log% 2>>&1

Simply change manager1.fqdn in the third line to the FQDN of your second site’s AV VIP. If you have a more than 2 sites, we can have a batch file for each site and just specify which bat file to run in each pool setting. If using Horizon, this is as simple as configuring a Post-Sync script under Guest Customization in the pool settings:

Once the desktops are provisioned, the script should run and log the results to C:\scripts\AppVolSwitch.log. Upon login, you should be communicating with the correct App Volumes instance. Hope this helps!