Tuesday, October 20, 2015

Branding Image Version in Registry using TASKSEQUENCEVERSION TS Variable

For sometime now I have been branding my image versions into the registry by leveraging the TASKSEQUENCEVERSION Task Sequence Variable.  This variable contains the value set as the Task Sequence Version in the Task Sequence Properties in the MDT Workbench.  I also setup a registry entry which will display the Image Version in the right click context menu when any folder on a deployed machine with that image is clicked.  It popped up in a forum today that a fellow Imaging architect was looking to do something similar here is my solution.
 
First here is a link to my script to do the work:
 
The script was created using ZTITemplate.wsf so functions as a standard script in MDT generating entries in BDD.Log and in its own log.  It was originally created in BDD 2007 and has continued to work through all versions up to and including MDT 2013 Update 1.
 
The script does a number of things for me beyond the image version stamping however here are the relevant things to do to get the image version functionality:
 
  1. Place in the "Scripts" directory of the MDT Deployment share you use to build the image
  2. Edit the script Define the "MyCompany" variable on line 81
  3. Set the Task Sequence Version to whatever is Sensible for your Environment in the Task Sequence Properties for the Task Sequence that builds the Image in the MDT Workbench (see Screenshot1 and Screenshot2)
  4. Add a Run Commandline Step to the Task Sequence to Call the Script to be run as part of the build Task Sequence the Logical place for this is under "Custom Tasks" (See Screenshot3)
  5. Build Your Image
 
Further Explanation:
 
  1. Line 79 of the script gets the value of the Task Sequence variable "TASKSEQUENCEVERSION" and stores it in the VBScript Variable "buildversion" for later use
  2. The code block at line 100 makes use the "buildversion" variable to build a registry entry which adds the Image Version String defined as the Task Sequence Version to the context menu when a Folder is right clicked (See Screenshot4) 
    Note: We call our Images the Standard Client, Thus the SC Notation prepended at line 102, its safe to take that out if you don't want that in your Image
  3. The code block at line 105 stamps the Version information into the registry in an easily collectable registry hive.  The location referenced existed at my company before I was hired and took over imaging so that is what we have continued to use as a standard location to collect image information, We put a lot more there.  The location predates the use of MDT at the company which I introduced when I arrived otherwise I'd have put all the info in "Deployment 4".  The referenced registry path (Line 106) could easily be updated to place the information in the standard location
    regPath = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Deployment 4\ImageVersion"
  4. Finally the Code Block at line 224 defines a Function which is used to perform each write to the registry so its done in a standard and logged manner

Screenshots:
Screenshot1

Screenshot2

Screenshot3

Screenshot4