5 June 2017

SCCM OSD - Dynamically Install Applications and Packages (Part Two)

This is a continuation of how to configure your OSD task sequence to install Applications and Packages dynamically. First post is here.

The example

The following example assumes that the environment is a little complex. If you plan things right at the start, you're going to have a much easier time later on when you need to make changes. What I've done is I've set myself some self-imposed numbering rules which I'll explain below. I also make use of the Set Dynamic Variables step to define my applications and packages. There are two reasons why I choose this over defining the software in an MDT CustomSettings.ini file. The first reason is I'm impatient. Any change to the INI file means I need to update my content and wait for it to distribute. In small environments this is not such a big deal but I've seen delays in bigger environments when a lot more content is being thrown around. Making a change to a task sequence and waiting for that change to replicate is much faster so that's why I utilise the task sequence a bit more. The other reason is possibly my failing. I could only get the variable Applications to work in CustomSettings.ini. Other variables I defined were ignored. I was under some time pressure so couldn't spend any real time looking into the issue. However if I could get this method to work, I would still choose setting dynamic variables every time because of the first reason.

Here's a small tip, when you've finished building your TS and are ready to test, change the name of the task sequence slightly. When you see that TS name change on your test machine then you know you're ready to go.

Building the task sequence

1. Decide on what your variables names are going to be. In this example I've decided to use APPLICATIONS###. At this point I can still use 3 suffix numbers as this is not the variable SCCM will use when it comes to actually installing the applications. I like 3 numbers as it gives me future flexibility if I need to add more self-imposed rules. Likewise the variable for packages is PACKAGES###.

2. In the State Restore phase of the TS, I've added a Set Dynamic Variable step, inserted the applications I deem mandatory and assigned them to the variable APPLICATIONS. The self-imposed rule is mandatory applications will occupy numbers 001-029.



As this example relates to applications, and remembering what I said in my previous post, you need to use the Application name.

3. Next I'm defining my country and regional specific software. The rule here is that software specific to a country occupies 030-039 while regional software has 040-049. Do the same as before. Here I've added a 7-Zip application.



4. Usually there is some sort of driver that I need to package because still to this day manufacturer's can't get it right. The rule for model specific software is that it occupies 050-070.



The above screenshot is an example of how define the variables for packages. As mentioned earlier, the format required is PackageID:ProgramName. The screenshot below shows where to find that information.



5. Now it's time to re-sort our application list. If the coalesce step is missing then add a Run Command Line step immediately before Install Applications. In the Command Line section enter:


cscript.exe "%deployroot%\scripts\ZTICoalesce.wsf" /CoalescePattern:Applications /CoalesceTarget:CoalescedApps /CoalesceDigits:2



Let's break down the switches;
  • CoalescePattern is asking for the dynamic variable we've been assigning to our applications. The script will enumerate all applications we've assigned to the variable Applications.
  • CoalesceTarget is asking for the output variable that the script will use to bring all our applications together into a new sequential list. In this example I've used CoalescedApps.
  • CoalesceDigits defines the numbered suffix of CoalescedApps. Recall earlier that I said Applications must only have a 2 digit suffix? That's why the number is 2.
6. This is the last step for our applications. All I need to do is define the Base Variable Name that the sequence will use to install the applications. This is the new list I mentioned in the previous step, CoalescedApps.



7. Packages follows the same process except for the suffix. It needs to be 3 digits. So the command line you use is:


cscript.exe "%deployroot%\scripts\ZTICoalesce.wsf" /CoalescePattern:Packages /CoalesceTarget:CoalescedPkgs /CoalesceDigits:3



8. On the Install Package step change the Base Variable Name to CoalescedPkgs.


Now we're all set to test our task sequence. The two logs to check if things aren't working are ZTICoalesce.log and SMSTS.Log. Here is a working example of the two logs in relation to packages.


ZTICoalese.log


SMSTS.log

You can see the ZTICoalesce.log re-orders the packages from PACKAGES051-053 to CoalescedPkgs001-003. SMSTS.log just verifies that the packages installed.

That brings this two part post to an end. I hope that all made sense.

-- Matt

1 comment:

  1. Could you please provide the ZTICoalesce script, the script which i'm suing from ADK contains and able to check only packages not the appliactions.

    ReplyDelete