Playing around with our Task Sequences in SCCM I came to the realization that we have numerous post install tasks for optional software when an Imaged PC is for a particular department or entity. This is due to different departments having different software requirements. I started toying around with the idea of a software selection GUI as part of the Task Sequence that will allow customization of post install software in the aim to make all deployments ‘one touch’.
After some research and work I came up with a basic GUI with a few customization's:
However, this is still limited and does not cover all of our use cases, so we are still left with some post install tasks. After some more work I came up with the following ‘final’ GUI:
From this GUI we are able to choose all the combinations of required software for all departments and entities. No more post install tasks for any PC’s.
I had to do a few things to get this working as desired. But at the core of it, each of the tick boxes sets an MDT Task Sequence Variable. The variable weather ticked or not determines if the software installation step should proceed.
MDT Task Sequence Variables
The task sequence itself has some additional steps to create the variables. Each variable requires a separate step for the variable creation. I found the variables needed to be created in the task sequence before the PowerShell script that sets the variables values can be run.
All of the variable are set to False when created in the task sequence. The PowerShell script will later set the ones that are ticked to True.
Conditional Application Installations
We have the requirement that some applications are installed on every PC that we image, these applications are installed regardless of the options chosen. For the conditional application installations, I have created a separate step for each one.
Each of these steps simply installs a single application.
Under options I have set the condition that the Task Sequence Step only run if the corresponding variable is set to True.
The PowerShell Script
Creating GUI’s in PowerShell is tedious and annoying but there is plenty of information on how to do that so I will be glossing over the GUI creation part. The important part of the script is retrieving the value from the check box and injecting it into the Task Sequence variable. A minimal example how this works would be:
#Get Variable from Form $installPDF = $pdfCheck.Checked #where $pdfCheck is the checkbox #set variable in the task sequence $TSEnv = New-Object -COMObject Microsoft.SMS.TSEnvironment $TSEnv.Value("installPDFAnnotator") = "$($installPDF)"
The script needs to be made into an SCCM Package so that we can run the script from the Task Sequence. The source contents for the package should include the script to be run, ServiceUI.exe and any assets required by the script. In my case the company logo.
The package is nothing special, you only need to set the source files for it. And distribute it the required Distribution Points.
Incorporating the script into the task sequence requires adding a step ‘General > Run Command Line’. The command line step should look similar to the following:
The two main things to note here is the command line is pointing to the PowerShell script that is part of the package and that the package is selected. You just need to make sure that you declare all the MDT Task Sequence variables before running the PowerShell step “Prompt For Image Configuration”
And that should be it!