So on a recent VDI engagement where I designed and installed a Server 2012 Pooled VDI enironment, along with App-V integrated with Microsoft System Center 2012 Configuration Manager (streaming), I ran into an issue where the policy retrival cycle from ConfigMgr was taking up to the full 60 minutes. This means that the users logging into this VDI may have to wait up to an hour before their App-V apps were available. Definitely unacceptable, and I came up with a few solutions. First option was to create a separate Client Policy in ConfigMgr, just for the VDI environment and set that policy poll interval at 3 minutes (the lowest you can set it), but that still means users could have to wait up to 3 minutes and would generate much more network traffic to the ConfigMgr environment. Not acceptable, my client says.
My second thought was to pre-cache App-V apps into the parent VDI image, but this would require more work and more frequent management of the parent image which is also not acceptable.
My solution? Well, have you ever heard of SetupComplete.CMD? Neither have I. SetupComplete.CMD is a script that can be stored in $WINDIR%\Setup\Scripts and will be run during sysprep setup of a new computer, at the very end of the sysprep process. Perfect!
So next we need to understand how the Sysprep process works for Server 2012 VDI. Tthe sysprep happens when the Virtual Destop is being created, and after sysprep the VM is snapshotted and put into a saved state. We can't have the SetupComplete.CMD run the policy check, because it won't do it when a saved Virtual Desktop is resumed and logged into. The solution, have SetupComplete.CMD create a Schedule task that runs a batch file 15 seconds after a user logs into the Pooled Virtual Desktop, and have that batch force the ConfigMgr client to request for new policies. Genius!
So here are my scripts:
SetupComplete.CMD
SCHTASKS /CREATE /TN "ConfigMgrPolicyPoll – On Logon – 15s" /SC ONLOGON /RU "System" /DELAY 0000:15 /TR C:\Windows\Setup\Scripts\ConfigMgrPolicyPoll.bat
ConfigMgrPolicyPoll.BAT
REM Force DDR
WMIC /NAMESPACE:\\ROOT\CCM PATH sms_client CALL TriggerSchedule "{00000000-0000-0000-0000-000000000003}"
REM Force Machine Policy Assignments Request
WMIC /NAMESPACE:\\ROOT\CCM PATH sms_client CALL TriggerSchedule "{00000000-0000-0000-0000-000000000021}"
REM Force Machine Policy Evaluation
WMIC /NAMESPACE:\\ROOT\CCM PATH sms_client CALL TriggerSchedule "{00000000-0000-0000-0000-000000000022}"
Works like a charm and ConfigMgr policy are pulling down within 10 seconds after login. This means App-V application icons are popping up on the desktop and are ready to go for the user. Let me know what you think!