MSEndpointMgr

Create a Deployment Package in ConfigMgr 2012 with PowerShell

During a migration project at one of my customers, we needed to create a few Deployment Packages and wanted to do that with PowerShell. So I imported the ConfigMgr PowerShell module, and to my surprise I couldn’t find any New-CMDeploymentPackage cmdlet. I’m not sure why this haven’t been added to the module yet by Microsoft, but I sure needed such a cmdlet for the task ahead. To overcome the lack of that particular cmdlet in the module, I set out to create a script myself that would do what you’d expect of a cmdlet like New-CMDeploymentPackage.

Download the script

I’ve made the script available for download on the TechNet Gallery.

Purpose

With this script you can create Deployment Package with PowerShell. A Deployment Package is used when downloading Software Updates in ConfigMgr 2012 and above. The only way to create a Deployment Package is through the wizards when you choose to download one or several Software Updates or when creating an Automatic Deployment Rule.

Usage

There’s a few key factors when using this script that you need to know of. I’ve given the script the ability to leverage common PowerShell parameters like Verbose, WhatIf and Confirm. In addition I’m leveraging the Cim cmdlets instead of the legacy Wmi cmdlets like Get-WmiObject etc. The script has some additional logic to check if there’s already a Deployment Package with the same name as specified to the Name parameter. It even checks if the specified source path exists on any of the existing Deployment Packages. I’ve added this functionality to avoid issues where this would simply generate standard WMI errors that are hard to interpret if you’re not familiar with the code being executed.
Here’s how you’d use this script in order to create a Deployment Package on a Central Administration Site server called CAS01 with the following criteria:
Name: Critical and Security Updates
Description: Critical and Security
Source Path: \\CAS01\Source$\SUM\ADRs\CSUpdates
1. Download the script from the TechNet Gallery link above.
2. Extract the script to e.g. C:\Scripts.
3. Open an elevated PowerShell console and browse to where you’ve extracted the script, e.g. C:\Scripts.
4. Run the following command:

.\New-CMDeploymentPackage.ps1 -SiteServer CAS01 -Name "Critical and Security Updates" -Description "Critical and Security" -SourcePath "\\CAS01\Source$\SUM\ADRs\CSUpdates" -Verbose
116_1

Results

As you can see from the picture above, we successfully create a Deployment Package with the specified critiera. If we take a look in the console, we should be able to see the Deployment Package:
116_2
I hope that Microsoft will include a New-CMDeploymentPackage cmdlet in the next Cumulative Update, but until then, this will do just fine.

Nickolaj Andersen

Chief Technical Architect and Enterprise Mobility MVP since 2016. Nickolaj has been in the IT industry for the past 10 years specializing in Enterprise Mobility and Security, Windows devices and deployments including automation. Awarded as PowerShell Hero in 2015 by the community for his script and tools contributions. Creator of ConfigMgr Prerequisites Tool, ConfigMgr OSD FrontEnd, ConfigMgr WebService to name a few. Frequent speaker at conferences such as Microsoft Ignite, NIC Conference and IT/Dev Connections including nordic user groups.

1 comment

  • Does this script also do the actuall downloading of the updates? Trying to find a way to schedule the download of updates to the Site Server to happen after hours.

Sponsors