Setting SMSDP When MDT Doesn’t Set It For You

Although you won’t find it mentioned in the MDT documentation, in an OSD task sequence the MDT Gather step will attempt to set a variable called SMSDP to the distribution point server name from which the boot image was obtained.  This can be handy if you want to do something like copy the logs to a “local” DP.

  MDT does this in the GetDP function in the script ZTIGather.wsf.  It uses the following logic:

  • Get the boot image ID by looking at the value of the _SMSTSBootImageID variable, e.g. PRI00001.
  • Use that value to form the name of the variable to retrieve, _SMSTS%_SMSTSBootImageID%, e.g. _SMSTSPRI00001, then retrieve the value of that variable.
  • Split that variable on all “,” values, then pick the first non-SMSPXEIMAGES$ path.
  • Parse the string to get just the server name.

Unfortunately, this method that MDT uses to determine the “local” DP name has some issues.  First, if you do not have a boot image associated with the task sequence then SMSDP will never have a value.  Second, during a refresh task sequence the _SMSTS%_SMSTSBootImageID% variable will not have any value until the content is requested and downloaded.  So from the beginning of the task sequence until the reboot into WinPE, SMSDP will never have a value.

To get around these limitations I created a function that uses the following logic:

  • Load task sequence XML from the _SMSTSTaskSequence variable.
  • Find the package IDs for the referenced packages.
  • For each package query the _SMST<package ID>, _SMSTSMB<package ID>, and the _SMSTHTTP<package ID> variables in turn.
  • If a value is found it will split that variable on all “,” values, then pick the first non-SMSPXEIMAGES$ path.
  • Parse the string to get just the server name.

So with this logic, as long as any package has been requested and download SMSDP should get a value.  Since the Use Toolkit Step runs very early, this code only has to run after that step to be successful.  I created a function called GetSMSDP and placed it in the HelperFunctions class of the library script that I have been building up over the years called MDTLibHelperClasses.vbs.

I have provided two methods of using this function.  The first is to call it directly from CustomSettings.ini using MDTLibHelperClasses.vbs as a User Exit script during the Gather step.  Place MDTLibHelperClasses.vbs in the MDT Toolkit package Scripts folder.  You will also need to place a MDTExitInclude.vbs from a previous post in the MDT Toolkit package Scripts folder.  Make the following additions to CustomSetting.ini in the MDT Settings package:

[Settings]
Priority=IncludeExitScripts, SetSMSDP
Properties=ExitScripts(*), SMSDP

[IncludeExitScripts]
UserExit=MDTExitInclude.vbs
ExitScripts001=#Include("MDTLibHelperClasses.vbs")#

[SetSMSDP]
SMSDP=#oHelperFunctions.GetSMSDP()#

The second method is to run this as a script in a Run Command Line step.  Place MDTSetSMSDP.wsf and MDTLibHelperClasses.vbs in the MDT Toolkit package Scripts folder.  Then create a Run Command Line step shortly after the first Gather step with the following command line:

cscript "%DeployRoot%\Scripts\MDTSetSMSDP.wsf"

Both MDTSetSMSDP.wsf and version 2.1.4 of MDTLibHelperClasses.vbs (the latest as of this writing) can be found in the attached Zip file.

 

Disclaimer: The information on this site is provided "AS IS" with no warranties, confers no rights, and is not supported by the authors or Microsoft Corporation. Use of included script samples are subject to the terms specified in the Terms of Use .

This post was contributed by Michael Murgolo, a Senior Consultant with Microsoft Services - U.S. East Region.

SMSDP_scripts.zip