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.
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.
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
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:
I hope that Microsoft will include a New-CMDeploymentPackage cmdlet in the next Cumulative Update, but until then, this will do just fine.