Restoring the SMSDP Variable in ConfigMgr 2012
(Originally posted 10/15/2013. Reposted for reference)
A recent ConfigMgr migration project turned up an environment variable that has been around since the SMS days but has recently fallen out of favor. That variable is SMSDP, which is intended to provide reference to the Distribution Point providing content for a Task Sequence execution. Following the aforementioned migration, the functions that had been leveraging this variable in the Task Sequence (in this case, it was being used to determine which CustomSettings.ini file to process). So a little investigation was required to track down and resolve the issue. While this variable is considered legacy and is not necessarily recommended for ongoing use, hopefully the information below will provide assistance for those relying upon the variable or seeking to use it in the future.
The SMSDP variable is created and populated by the ZTIGather.wsf script in the MDT Toolkit in the following section:
Function GetDP
Dim sSMSDP
oLogging.CreateEntry “Getting DP info”, LogTypeInfo
‘ If OSD, get the DP server
sSMSDP = “”
If oEnvironment.Item(“_SMSTSBootImageID”) <> “” and oEnvironment.Item(“_SMSTSMediaType”)<> “FullMedia” then
Dim arrSMSDP,aSMSDP‘ Get the first path from the comma-delimited list
arrSMSDP = Split(oEnvironment.Item(“_SMSTS” & oEnvironment.Item(“_SMSTSBootImageID”)),”,”)
For Each aSMSDP in arrSMSDP
If Instr(aSMSDP,”SMSPXEIMAGES$”) = 0 Then
sSMSDP = aSMSDP
Exit For
End If
Next‘ Figure out if it is a UNC or a URL, and extract the server name as appropriate
If Left(sSMSDP, 2) = “\\” then
sSMSDP = Mid(sSMSDP, 3)
sSMSDP = Left(sSMSDP, InStr(sSMSDP,”\”)-1)
ElseIf Left(sSMSDP, 7) = “http://” then
sSMSDP = Mid(sSMSDP, 8)
sSMSDP = Left(sSMSDP, InStr(sSMSDP,”/”)-1)
ElseIf Left(sSMSDP, 8) = “https://” then
sSMSDP = Mid(sSMSDP, 9)
sSMSDP = Left(sSMSDP, InStr(sSMSDP,”/”)-1)
End If
End if
If sSMSDP = “” and Left(oUtility.ScriptDir,2) = “\\” then‘ Assume we are running from a DP (maybe not always accurate, e.g. NewComputer phase)
sSMSDP = Mid(oUtility.ScriptDir,3)
sSMSDP = Left(sSMSDP, InStr(sSMSDP,”\”)-1)End if
If sSMSDP = “” then
oLogging.CreateEntry “Unable to determine ConfigMgr distribution point”, LogTypeInfo
Else
oLogging.CreateEntry “ConfigMgr distribution point = ” & sSMSDP, LogTypeInfo
oEnvironment.Item(“SMSDP”) = sSMSDP
End ifoLogging.CreateEntry “Finished getting DP info”, LogTypeInfo
End function
Basically, the script retrieves the PackageID of the boot image (“_SMSTSBootImageID“), then attempts to retrieve the Distribution Point location from which the boot image was downloaded by appending the PackageID to “_SMSTS” and parsing the server name out of the value returned.
(As a side note, in SCCM 2007 environments the value of the SMSDP variable can be either just the server name or the FQDN of the server, depending on whether the intranet FQDN is entered on the DP site system properties. In ConfigMgr 2012, the FQDN is always used, so in the event of migration from SCCM 2007 to ConfigMgr 2012 make sure whatever processes utilitize the SMSDP variable are capable of handling the FQDN.)
The problem with SMSDP comes with the built-in variables in ConfigMgr 2012. Specifically, the _SMSTS<PKGID> variables corresponding to the Task Sequence content dependencies are no longer populated:
This of course results in the script not being able to determine the Distribution Point:
As it turns out, ConfigMgr uses a different set of variables for presenting the Distibution Point location of Package dependencies. Instead of _SMSTS<PKGID>, the information is held in _SMSTSHTTP<PKGID>:
This actually makes the fix very simple. All that is required is to update the line in ZTIGather.wsf that identifies the Boot Image reference to use _SMSTSHTTP as the prefix:
Change…
arrSMSDP = Split(oEnvironment.Item(“_SMSTS” & oEnvironment.Item(“_SMSTSBootImageID”)),”,”)
…to…
arrSMSDP = Split(oEnvironment.Item(“_SMSTSHTTP” & oEnvironment.Item(“_SMSTSBootImageID”)),”,”)
Now when the ZTIGather.wsf script is run, the SMSDP variable is successfully populated:
As of the MDT 2013 Preview release, the ZTIGather.wsf script still refers to _SMSTS<PKGID> for the SMSDP variable, presumably to preserve backwards compatibility with the SCCM 2007 environment for ConfigMgr integration. To preserve this functionality across both, replace the line referenced above with the following:
If oEnvironment.Item(“_SMSTS” & oEnvironment.Item(“_SMSTSBootImageID”)) <> “” Then
arrSMSDP = Split(oEnvironment.Item(“_SMSTS” & oEnvironment.Item(“_SMSTSBootImageID”)),”,”)
Else
arrSMSDP = Split(oEnvironment.Item(“_SMSTSHTTP” & oEnvironment.Item(“_SMSTSBootImageID”)),”,”)
End If
This will defer to the default variable unless it is empty, in which case it will pull from the newer variable.
UPDATE: As of MDT 2013 U2, this issue still exists.