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.
Prerequisites :
- 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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
@echo off cls echo ************************************************************ echo ***** This will prepare the machine for Standard Image ***** echo ************************************************************ echo. choice /c yn /m "Do you want to Download and Install Windows Updates" set DRIVENUM=%ERRORLEVEL% if %DRIVENUM% EQU 1 goto wsus if %DRIVENUM% EQU 2 goto ctx :wsus echo. echo Enable and Start Windows Update Service sc config wuauserv start= auto net start wuauserv echo. echo Applying Windows Updates wuinstall /install shutdown /r /t 0 goto ctx :ctx echo. choice /c yn /m "Do you want to Download and Install Citrix Hotfixes" set DRIVENUM=%ERRORLEVEL% if %DRIVENUM% EQU 1 goto 65update if %DRIVENUM% EQU 2 goto cont :65update call C:\XA65Update\XA65Update.cmd :cont echo. choice /c yn /m "Do you want Defrag the Disk" set DRIVENUM=%ERRORLEVEL% if %DRIVENUM% EQU 1 goto defrag if %DRIVENUM% EQU 2 goto cont1 :defrag echo. defrag C: :cont1 echo. ipconfig /flushdns echo. echo Deleting Windows Update Download Folder rmdir /s /q "C:\Windows\SoftwareDistribution\Download" echo. echo Deleteing Downloaded Citrix Hotfixes del C:\XA65Update\*.msp /q /s echo. echo Start AntiVirus Prescan net start MsMpSvc call "C:\Program Files\Microsoft Security Client\MpCmdRun.exe" -Scan -Scantype 1 net stop MsMpSvc echo. echo Running <span style="text-decoration: underline;">Provisioning Services</span> Optimization Tool call "c:\Program Files\Citrix\Provisioning Services\TargetOSOptimizer.exe" echo. 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 1.1.1.1 -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.
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.
Agree
Hi
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)
http://www.out-web.net/?p=1164
Fps
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:
Server Name
Credentials (optional)
Create new vDisk
User existing vDisk
vDisk Name
Store
vDisk Type
vDisk block size
MS Licensing options
Image volumes
Target device name
MAC
Collection
Optimize
I couldn’t find any switches or config file into which the settings are saved and read from when the machine reboots.
Any ideas??
Thanks.
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.