Using SCCM Collection variables in Task Sequence

For this post, I’ve built a little scenario to explain how to use SCCM Collection variables in Task Sequence.

I get often asked how to reduce the number of SCCM task sequences and how to make them dynamic. I’m always surprised when I hear from an SCCM administrator that they don’t use variables in their task sequence.

Let’s say you are working in an international company and use SCCM to deploy operating systems. Each office has its own configuration and specific software to install. You decide to create 1 task sequence per office. Wrong! You’ll end up in a management nightmare. One task sequence is often enough and this is where you need variables to the rescue.

The magic that you need to understand is collection variables. You have 2 choices, let the user enter the variable value at the beginning of the deployment (explain later) or pre-load these values using collection variables. I prefer the second option which speeds up the deployment process.

Scenario :

  • You manage SCCM for 3 offices (Alabama,Boston and Charlotte)
  • Each Office have a different Administrator password, different timezone, place their computer in different OU in Active Directory
  • Alabama Office needs Office 2010, Adobe Flash 15 and 7zip
  • Boston Office needs Office 2013 and Adobe Flash 11
  • Charlotte Office needs Adobe Acrobat Reader XI

Here is how to achieve this :

SCCM Collection variables Task Sequence Step-by-Step Guide

#1 – Create your OSD Collections

Create 1 collection per office. For this post, I created 3 collections Offices in Alabama, Boston, and Charlotte. Each Office will receive different configurations and software based on their variables.

SCCM Collection variables Task Sequence

#2 – Create your Office variable

  • Right click the Alabama collection
  • Select Properties
  • Select the Collection Variables tab
  • Click the star icon
  • Create a new variable named Office
  • Give it a value of Alabama
  • Repeat steps for Boston and Charlotte collection

You’ll end up with 3 collections with their variables having different values.

Collection variables Task Sequence

#3 – Open your task sequence and create condition based on those variable

*I assume that you already have a functional task sequence.

  • Open Software Library \ Operating Systems \ Task Sequences
  • Right Click your task sequence
  • Select Edit
  • To place the computer account in a specific OU :
    • Browse to the Apply Network Settings Section
    • Create 3 Apply Network Settings steps, 1 for each site
    • Click Add, Setting, Apply Network Settings
    • On each Office configure the Name and Domain OU to fits your needs
SCCM Collection variables Task Sequence
  • On the Options Tab
  • Click Add Condition
  • Select Task Sequence Variable
  • Enter the variable name Office
  • Condition : Equal
  • Value : Alabama
Collection variables Task Sequence
Collection variables Task Sequence

***Repeat above steps for Boston and Charlotte changing the value of the variable***

  • Browse to the Apply Windows Settings Section
  • Create 3 Apply Windows Settings steps, 1 for each site
  • Click Add, Setting, Apply Windows Settings
  • On each Office configure the TimeZone and Administrator password
SCCM Collection variables Task Sequence
  • On the Option Tab
  • Click Add Condition
  • Select Task Sequence Variable
  • Enter the variable name Office
  • Condition : Equal
  • Value : Alabama
Collection variables Task Sequence

***Repeat above steps for Boston and Charlotte changing the value of the variable***

  •  Browse after the Setup Windows and Config step
  • Click Add, General, Install Application
  • Create 3 Install Application steps, 1 for each site
  • On each step configure the desired software
SCCM Collection variables Task Sequence
  • On the Option Tab
  • Click Add Condition
  • Select Task Sequence Variable
  • Enter the variable name Office
  • Condition : Equal
  • Value : Alabama

***Repeat above steps for Boston and Charlotte changing the value of the variable***

Summary

So what we basically did in the previous steps is told the task sequence to run our step based on the Office variable value.

Next, you need to deploy your task sequence to the 3 collections. Ask your IT guys in Alabama, Boston, and Charlotte to use their respective collections.

When the task sequence runs, it will evaluate each step and run only the Alabama step when in the Alabama collection, the Boston step when in the Boston collection, and the Charlotte step when in the Charlotte collection.

Verification

  • Start a task sequence
  • Open Monitoring\Overview\System Status\Status Message Queries
  • Select All Status Messages from a Specific System
  • Enter your machine name and select 1 hour ago
SCCM Collection variables Task Sequence
  •  Follow the installation process
  • Then the task sequence evaluate a variable you’ll see this message
1766 (11)
  • You will see when your variable gets skipped meaning that it works

SCCM Collection variables Task Sequence – Extra

If you prefer to have only 1 collection for OSD and ask you IT people to fill in the Office variable, you can achieve that easily.

  • Do the same procedure but create only 1 collection for OSD
  • Create the Office variable on this collection but leave the value empty
SCCM Collection variables Task Sequence
  • Doing so, the task sequence will start and wait for a value to be entered in the Office variable
  • Double-click the value and enter Alabama, Boston or Charlotte and the task sequence will deploy options based on the designated office
Collection variables Task Sequence

From there, only imagination is the limit. You now understand the power of the variable in a task sequence. Use it in order to maintain the lowest amount of task sequence in your organization.

Read more about variables on Technet.

You can create you collection variable using PowerShell but for now, the cmdlet is broken in CU3. If you need to script the variable creation you must use WMI function for now.