In this blog post I will show you my Prepare for PVS script that contains Best Practices obtained after years of experience with Provisioning Services.
Let’s say you’re going to run Windows Updates. Well since you’ve already launched the Target Optimizer tool, that services is disabled and you need to head into services, enable and start it. Run Windows update and all good. When the update is finished you shutdown the machine and switch from Private to Standard Mode.
What you didn’t remember was to reboot the server for Windows Update to complete it’s updates. What happens now, is that every time your servers reboot, Windows Update will kick in and finish it’s things.
So being only one administrator doing all the procedures is one thing, but when you hand over the solution to your customer or maintenance team, everybody would probably do this differently, forgetting to flush DNS and so on.
So this script will do all these thing for you. Just teach your staff to always run the script after maintenance.
- Download Wuinstall
- Download and Install XenAppCloning Tools (Now free of use).
- Download Citrix XenApp 6.x Update Script
Copy Wuinstall to C:\Windows. Run XenAppCloning tool, add your free license and then configure your settings and save the settings to the configuration file.
Extract the XAUpdate script to C:\XA65Update, rename the script to XA65Update.cmd and configure the settings required inside that script.
Copy the content below into C:\Program Files\Citrix\Prepare for PVS.cmd
echo ***** This will prepare the machine for Standard Image *****
choice /c yn /m "Do you want to Download and Install Windows Updates"
if %DRIVENUM% EQU 1 goto wsus
if %DRIVENUM% EQU 2 goto ctx
echo Enable and Start Windows Update Service
sc config wuauserv start= auto
net start wuauserv
echo Applying Windows Updates
shutdown /r /t 0
choice /c yn /m "Do you want to Download and Install Citrix Hotfixes"
if %DRIVENUM% EQU 1 goto 65update
if %DRIVENUM% EQU 2 goto cont
choice /c yn /m "Do you want Defrag the Disk"
if %DRIVENUM% EQU 1 goto defrag
if %DRIVENUM% EQU 2 goto cont1
echo Deleting Windows Update Download Folder
rmdir /s /q "C:\Windows\SoftwareDistribution\Download"
echo Deleteing Downloaded Citrix Hotfixes
del C:\XA65Update\*.msp /q /s
echo Start AntiVirus Prescan
net start MsMpSvc
call "C:\Program Files\Microsoft Security Client\MpCmdRun.exe" -Scan -Scantype 1
net stop MsMpSvc
echo Running <span style="text-decoration: underline;">Provisioning Services</span> Optimization Tool
call "c:\Program Files\Citrix\Provisioning Services\TargetOSOptimizer.exe"
echo Running XenApp Cloning Tool
call "C:\Program Files (x86)\VirtuAll Solutions\XenApp Cloning Tool\XenAppCloningCmd.exe" -Mode:PVS -ConfigFile:"C:\Program Files (x86)\VirtuAll Solutions\XenApp Cloning Tool\SilentCloningConfig.ini"
ping 22.214.171.124 -n 1 -w 5000 > nul
shutdown /s /t 30 /c "The System will Shut Down in 30 seconds - Type shutdown /a to Abort"
To get ride of this annoying boot screen
you just added HKLM\Software\Citrix\ProvisioningServices\SkipBootMenu to your PVS servers. Now your maintenance / test machine will automatically boot to the newest version of the vDisk.
Please be aware that this doesn’t work on Provisioning Services 6.2 hosted on Windows 2012. The good news though, the KMS bug has finally been fixed in Provisioning Services 6.2 (part of Project Excalibur Tech Preview).
So when you e.g. want to patch your Provisioning Services image with the latest Citrix Hotfixes, you just select that option and off you go. The server is rebooted automatically and when it comes back online you just run through the script another time and this time the server will be shutdown ready for you switching from private to standard mode.
If you have any other Best Practices for Provisioning Services, please leave a comment below and share with the community.
9 thoughts on “Best Practices Preparing a Provisioning Services vDisk”
I’m using very much the same procedure. Here are some additional stuff. If using MS antivirus, run a prescan on the image:
net start MsMpSvc
echo Start antivirus prescan
“C:\Program Files\Microsoft Security Client\Antimalware\MpCmdRun.exe” -Scan -Scantype 1
net stop MsMpSvc
Good point Magnar, if running antivirus make sure you do a prescan, as stated in the Project VRC document. The difference in performance are huge.
A couple of weeks ago, I’ve published a power shell script that I use to semi-automatically prepare a XenApp 6.x server for imaging with PVS. It automates the following steps:
– Investigate the PVS’ Personality.ini in the root of the system drive in order to determine the disk mode (read-write, read-only, or started from local HD)
– Start the Citrix IMA service
– Query XenApp Server Load. Exit if the query fails. Exit if the XenApp server count is below 3.
– Run XenAppConfigConsole to prepare the server for imaging. (Based on the script user’s choice locally stored XenApp database information will be either kept or cleared from mf20.dsn and LGPO. Default is keep db information. If you choose to clear them you need to provide DB information through GPO.)
– Clear XenApp related caches (LHC and RADE)
– Clear Citrix User Profile Manager’s cache
– Resync time
– Update GPO settings
– Clear network related caches (DNS and ARP)
– Clear WSUS Client related settings
– Clear event logs
– Based on the findings in Step 1, suggest a convenient main action, that is either “Exit” (if we’re in maintenance/private w/ read-write vdisk access), or “Invoke ImagingWizard” (if we started from local HD), or “Invoke XenConvert” (reverse imaging scenario w/ read-only vdisk access)
Hi Frank, I came across your script and wanted to know if you could throw any light on how to possible ways of scripting the ImagingWizard.exe (PVS 7.x) prompts:
Create new vDisk
User existing vDisk
vDisk block size
MS Licensing options
Target device name
I couldn’t find any switches or config file into which the settings are saved and read from when the machine reboots.
Have you found a fix for this for PVS 7 on Win2012 ?
I guess you think about the boot screen? http://www.cjharms.info/2013/06/skip-vdisk-boot-menu-under-pvs-70.html
Quick question on the script wouldn’t you want to delete any folders before doing the defrag?
Yes, just switched the lines.