top of page
  • Writer's pictureshishir kushawaha

Capture UDI Selected Applications in Task Sequence variable

MDT (Microsoft Deployment Toolkit) UDI (User-Driven Installation) is a deployment solution that allows users to interactively select applications, operating systems, language packs, and other deployment options during a deployment process. The application selection is an important aspect of the UDI process, and the PowerShell script provided here can be used to prepare a list of applications selected by the user during the UDI wizard. This script captures the application list from the task sequence variables and saves the list in another task sequence variable. It also saves the details in the log file. The captured application list can then be used for further processing as required by the deployment solution.

Script snippet: The entire code can be accessed from GitHub.

$tsenv = New-Object -ComObject Microsoft.SMS.TSEnvironment
while(($($tsenv.Value($var)) -ne ""))
    if($i -eq 1)

Variable Declaration:

  • $tsenv is an object of the Microsoft.SMS.TSEnvironment class, which is used to access environment variables in the Task Sequence environment. This object is created using the New-Object cmdlet and the -ComObject parameter.

  • $var is a string variable that stores the name of the applications stored in series of variables like Application001, Application002 etc.

  • $LogPath is a string variable that stores the log file path, obtained from the _SMSTSLogPath task sequence variable.

  • $logfile is the full path to the log file, which will be used to log the script's output. It is constructed by concatenating the value of $LogPath and the file name "WindowsDeploymentCustom.log".

  • $appfile is the full path to the file where the list of selected applications will be logged. It is constructed by concatenating the value of $LogPath and the file name "UDISelectedApps.log".

  • $applist is a string variable that will store the list of applications. It is initially set to an empty string. At the end, it will store the name of all the applications which user selected.

Processing of Code:

  • The while loop is used to repeatedly access task sequence variables starting with Application001, ..002, ..003 and so on until the value of the task sequence variable is an empty string.

  • Within the loop, the value of each task sequence variable is retrieved and its stored in $applist variable.

  • The final value of $applist is stored in the udiapplist task sequence variable using the Value method of the $tsenv object, so that it can be used elsewhere in the Task Sequence.

  • The log entry is written to the log file to indicate the start and end of the processing of the application list using the Write-Output cmdlet and the Out-File cmdlet. This helps in debugging the script and understanding its behavior.

157 views0 comments


bottom of page