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:
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:
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, SetSMSDPProperties=ExitScripts(*), SMSDP [IncludeExitScripts] UserExit=MDTExitInclude.vbs ExitScripts001=#Include("MDTLibHelperClasses.vbs")# [SetSMSDP]SMSDP=#oHelperFunctions.GetSMSDP()#
[Settings]Priority=IncludeExitScripts, SetSMSDPProperties=ExitScripts(*), SMSDP
[IncludeExitScripts] UserExit=MDTExitInclude.vbs ExitScripts001=#Include("MDTLibHelperClasses.vbs")#
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:
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.
This post was contributed by Michael Murgolo, a Senior Consultant with Microsoft Services - U.S. East Region.
THANK YOU!! This is exactly what I needed. It's a shame this variable was removed. I use it to set the path to my network migration storage path.