I have seen where PVS targets (mainly Desktop OS) will fail to activate via KMS after booting, and/or not get the proper group policy settings. I think this is because PVS hasn’t released the network when Windows is trying to activate/update gpo (or something along those lines). On top of this in my environment I have PvD and Random desktops booting off of the same vdisk image. To fix this I created the script below, and setup a scheduled task to run at startup (using SYSTEM account).
Note: Using this script you can do a lot more than just slmgr /ato and gpupdate /force commands. For instance if you have an antivirus service that you just want to start if the vdisk is in standard mode… you could just add a “start-service” command (of course you’d want that service to be set to manual). Feel free to edit however it suits your environment.
Steps to implement:
- Start a maintenance version of your vdisk
- Logon to that desktop/server
- Open powershell_ise, or notepad
- Copy the script below and paste it
- Edit line 2 to be the FQDN of your domain
Example: yourdomain.com - Save it (remember where you saved it) – I just save mine to the root of C:\ to keep it simple
- Open Task Scheduler
- Right click on “Task Scheduler Library” and select “Create a Basic Task”
- Name your task and optionally add a description and click Next
- On the Task Trigger screen select “When the computer starts” and click Next
- On the Action screen click Next (Start a program should be selected by default)
- On the Start a Program Screen
- Type the path, or browse to powershell.exe (C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe)
- in the Add arguments section:
- -executionpolicy unrestricted -file <path to the .ps1 file you just saved>
Example: -executionpolicy unrestricted -file c:\startup.ps1
- -executionpolicy unrestricted -file <path to the .ps1 file you just saved>
- Click Next
- Check “Open the Properties dialog for this task when I click Finish” and click Finish
- On the properties page click Change User or Group
- In the Select User or Group box type in “system” (no quotes) in the box and hit OK
- You should now see “NT AUTHORITY\SYSTEM” as the user account to run as
- Check the Run with highest privileges box, and click OK
- Perform any cleanup operations you typically do, run PvD inventory (if you use PvD), and shutdown the machine
- Place your vdisk into Test mode, and test away
- When satisfied set the vdisk to production
function startup {
while ((Test-Connection "fqdn of your domain ie: contoso.com" -count 1) -eq $null) {
Start-Sleep -Milliseconds 500
}
& cscript.exe c:\windows\system32\slmgr.vbs /ato
& gpupdate.exe /force
}
$p = gc c:\personality.ini
$r = (Get-ItemProperty registry::'HKLM\SOFTWARE\Citrix\personal vDisk\config').vhdmountpoint
if (($r -eq $null) -and (($p -like "*diskmode=p*") -or ($p -like "*writecachetype=0*"))) {
break
}
startup
Explanation of the script:
When executed it will get the content of c:\personality.ini and the value of REG_SZ vhdmountpoint. If personality.ini contains diskmode=p or writecachetype=0 and vhdmountpoint value is blank/non-existent it will stop the script (this indicates the vdisk is in private or maintenance mode).
PvD – value of vhdmountpoint will not be blank, so even if for whatever reason the .ini file shows the disk in private/maintenance it will go on and run the function
Shared Random – value of vhdmountpoint will be blank, but the .ini should show diskmode=s and writecachetype=something other than 0 (depends on the mode), so it will also run the function.
If the break condition is not met (indicating the disk is in shared mode) then it will run the startup function. This function tries to ping the fqdn of your domain 1 time. If it gets a reply it will run the activation command, and gpupdate. If it does not, it will wait half a second and try again… over and over until it gets a reply from the fqdn of your domain.
For clarification, you have the script check the PvD and write cache since the script will be in the master image. So, you don’t want it running when working in private or maint. mode. Is that right?
Doesn’t the personality.ini need to be checked first before running the slmgr.vbs /ato command?
Paul,
The personality.ini is checked first. The script actually starts doing things on the “$p = gc c:\personality.ini” line. Everything before that is in the startup function which is only called if personality.ini shows the vdisk is in shared mode. If it has “diskmode=p” or “writcachetype=0” in the file that indicates the vdisk is in private or maintenance mode and it runs “break” which ends the script. If it is in shared mode then the startup function is called.
[…] Automatically Activate (KMS) and Gpupdate PVS targets at Startup ? Citrixirc.com […]