SCCM Application PackagerSCCM Application Packager

Package Software While You Sleep Using the SCCM Application Packager Script

Don’t you love when Chrome, Firefox and Flash all release critical updates all at the same time? Packaging software that changes frequently was taking a lot of my time, I knew that there must be a better way. I search for solutions, but found nothing that satisfied my needs at the time. In the end, I decided to create my own solution. This solution became a powerful PowerShell script that required nothing but the internet, a console connection and the built-in ConfigurationManager module. The SCCM Application Packager script takes the work out of packaging applications by automating the Download, Packaging, Distribution and Deployment of applications using flexible XML files called “recipes”. The script is open source and available on GitHub for anyone to use! In this post I’ll go over the process of setting up the script so you can package applications while you sleep!

Prerequisites

We’ll start with a few prerequisites. You will need at least the following to get started with the scripts:

  • Computer that will do the packaging should have access to the SCCM Primary Site and the internet to download packages
  • SCCM Console installed and it is recommended, but not required, to connect to your site through the console at least once
  • I also recommend opening Internet Explorer once and going through the initial setup. This allows the script to download the applications without running into blocks

After you have confirmed you have the proper setup to run the script, you can begin downloading the script and setting up the preferences for your site.

Download the SCCM Application Packager tool from GitHub

  1. You can download directly from GitHub here: https://github.com/asjimene/SCCM-Application-Packager
  2. Unzip the downloaded file at a location of your choosing, I chose “C:\”.
  3. Navigate to “C:\SCCM-Application-Packager-master” and open the “SCCMPackager.prefs” file.

Setting up the SCCM Application Packager tool

  1. Set the ContentLocationRoot to your SCCM Content Folder. The script will create a folder for each application in this Content Folder.
  2. Set the IconRepo to the location where you store all of your icons if you don’t have an icon folder many are included with the Application Packager tool in the “ExtraFiles\icons” folder.
  3. Set the SCCMSite to your SCCM Site Code (Don’t forget the “:” at the end).
  4. If you would like an email sent at the end of the packaging, you can set the email preferences, otherwise set “SendEmailPrefences” and “NotifyOnDownloadFailure” to False
  5. Set the PreferredDistributionLoc to a Distribution Point Group that you want packages to be distributed by default
  6. Set the PreferredDeployCollection to a collection that you want packages to be deployed to by default

Running the initial setup

This creates an Application and some Global Conditions that the script uses as a template for requirements rules and install behavior

  1. Open a PowerShell Window in the SCCM Application Packager Directory and run the “SCCMPackager.ps1” script. Typing “powershell” in the location bar will automatically open PowerShell in the current directory.
  2. While the script is running, you can follow along by watching the log file, which is located by default at “C:\Temp\SCCMPackager”
  3. When the script has completed it’s first run, the log file will provide instructions on how to proceed. These extra steps allow the script to create applications that use Install Behaviors. Simply open your Configuration Manager Console and add an install behavior to the Application Requirements Template.
  4. Please note that some applications require the 7za executable from the 7-zip project to be packaged. I recommend downloading 7zip-extra from https://www.7-zip.org/download.html and copying the “7za.exe” file from there into the root of your SCCM Application Packager folder before continuing.
  5. You may also want to take advantage of the application icons that have already been specified in the Application Packager. There are application icons included for every recipe provided on the GitHub. Those can be found in the “ExtraFiles\icons” folder. I would recommend copying them to the “IconRepo” specified in step 2.
  6. Initial Setup is now complete! Time to package some Applications!

Packaging Applications

Once the initial setup is complete, packaging applications is as simple as copying or moving some files to a folder and running the script!

  1. Navigate to the SCCM Application Packager Script directory.
  2. Look through the “Disabled” folder and determine what XML files (called “recipes”) you want to package.
  3. Cut or Copy the recipes that you want to package from the “Disabled” folder into the “Recipes” folder.
  4. Run the “SCCMPackager.ps1” script using PowerShell, just as you did during the Initial Setup
  5. Sit back and relax! You can always look at the log file to see how packaging is proceeding. Once packaging is finished, it is always good to test the packaged apps to ensure they deploy and function in the way you expect. The applications the script creates will be fully featured, including icons, descriptions, estimated and max install times, and take advantage of requirements and Install behavior if needed.
    SCCM Application Packager

Automate packaging

Once the script is in good working order, I prefer to have everything happen automatically. My current preferred method of doing so is using the built-in Windows Task Scheduler to run the script weekly at 4 AM on Wednesday mornings. Feel free to adjust the schedule to your specific needs and goals.

  1. Open the Task Scheduler, and navigate to the Task Scheduler Library (I just search for it in the start menu, but you can go through MMC if you are feeling fancy.)
  2. Right click and create a new Basic Task.
  3. General Tab

    1. Name: “SCCM Application Packager” has a nice ring to it
    2. A Description of your choosing
    3. Choose the user account you want to run the script with, here I chose my regular user account, but in my Production environment I have a service account dedicated to the task (just make sure you log in with the service account and ensure it has done the IE setup and can get to the Console)
    4. Choose the “Run whether user is logged on or not” radio button.
    5. Some apps require the application be installed and uninstalled to figure out the version numbers and other information, so you may want to check the box to “Run with highest privileges” if any of your recipes require it.
  4. Triggers Tab

    1. Click “New…”, and choose: Run: “On a schedule”
    2. I chose Weekly at 4 AM on Wednesday.
    3. Stop the task if it runs longer than 2 hours
    4. Click “OK”
  5. Actions Tab

    1. Click “New…”, and choose “Start a program” as your Action
    2. Program/script: powershell.exe
    3. Add arguments: -executionpolicy bypass -file “C:\Path\To\SCCMPackager.ps1”
    4. Click “OK”
  6. Conditions

    1. The only condition I would check on this page may be “Start only if the following network connection is available” Otherwise, leave everything unchecked
  7. Settings

    1. Check “Allow task to be run on demand” (We will use this for testing)
    2. Stop the task if it runs longer than: ” hours”
    3. If the task is already running: “Do not start a new instance”
  8. Once the Scheduled Task is set up click OK, and enter your username and password to save the credentials to run if you aren’t logged in.
  9. Finally, right-click the newly created task and click “Run”, then watch the log file to ensure it is running properly.

Closing

That’s it! After everything is set up and you have the scheduled task created, the script will run when scheduled and download, package, distribute, and deploy your applications to your specified collection. All you have to do is test and deploy to production! If you set up the email feature, the script will email you a report of newly packaged applications and if it ran into any errors in the process.

If you think the SCCM Application Packager tool would make your life easier, you can find it at GitHub here: https://github.com/asjimene/SCCM-Application-Packager. I also happily accept pull requests with new features, or for recipes. If you are interested in creating recipes, stick around for Part 2, where I will go over how the script and recipes work!

Thank you for reading this post! I hope this script helps save a lot of time and headaches!

 

Andrew Jimenez

Twitter: @AndrewJimenez_

Andrew Jimenez

SCCM Administrator specializing in OSD, PowerShell, application packaging, and automation.

14 comments

seventeen + 13 =

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  • This works quite well so far. I just have the need to remove the “version” number in the “application” name within SCCM. Not the “deployment type” name.

    We have some fixed/static OSD options that look for an app, for example, called “Notepad++” and this packages it with “Notepad++ 7.7.1.0” which causes our OSD task to fail.

    • At this point in time, the Version being appended to the application is integral to the packaging process for the script. I will definitely consider making it optional in the future, but I would have to make some major changes in the script before doing so.

  • No problem at all. Like I said before, this is working quite well and is a very slick Powershell script. Excellent work!

  • Hi there!

    I just tried your awesome script and it seems like GoogleChrome gives me a PS error on an Extension Attribute. Is it only me?!

    Thanks!

  • Wow! Just started playing with this and it looks awesome for those rapidly updating apps.
    Only thing I’ve come across so far is the “localized Display Name” used in Software Center. I frequently make this different than the application name. Zoom, for example, the Application name is ZoomDesktopClient but the Localized application name we use on Software Center is “Zoom Desktop Client (participant only)”. Is there any way to add this as a separate config item in the recipe?

  • We unfortunately do not have any computers in our environment that can access both our SCCM site server and the internet… Is there any way to run the package downloads on one server, and then import those downloaded packages into SCCM from a separate server?

  • Andrew,
    Awesome script that I have been using in our company MECM environment. Do you do request for creating recipes? If so, would you be able to do one for Trimble Business Center?

Follow us

Don't be shy, get in touch. We love meeting interesting people and making new friends.

%d bloggers like this: