Serge Chegorian's System Center Blog

Serge Chegorian's System Center Blog

How to prestage a large number of applications in SCCM 2012

May 29th, 2015

In some circumstances specifically if you are dealing with a slow network package distribution over WAN may be unreliable and it would worth to prestage the content and then copy it to the remote Distribution Point using an alternative method, for example media sent with a courier. So the question is how to script out prestaging process for a large number of applications.

In SCCM 2012 SP1 onwards there is a new cmdlet Publish-CMPrestageContent. The syntax of this command is:

 

Publish-CMPrestageContent -<ApplicationId|PackageID|DriverPackageID|OperatingSystemImageID> <String[]>  -DistributionPointName <String[]> -FileName <String[]>

Where:

DistributionPointName is FQDN of the Distribution Point which already has a copy of the package. You cannot prestage a package until it is successfully distributed to at least one DP.

FileName is a prestage file name

For example:

Publish-CMPrestageContent -PackageID “XYZ000C0″ -DistributionPointName “XYZSERVER.LOCAL” -FileName “C:\Temp\XYZ000C0.pkgx”

The tricky bit here is that ApplicationID is a new, SCCM 2012 specific package ID which is different to the “classic” site code plus 5 digits package ID format. Fortunately every application has both new and classic ID’s. But keep in mind that if you decide to use SMS_Application WMI class in order to identify ApplicationID by PackageID it would fail because PackageID property of SMS_Application class is so called “lazy” property and is not populated.

You have to use SMS_CIContentPackage class or v_CIContentPackage view if you prefer SQL in order to establish relation between PackageID and ApplicationID.

In order to perform a bulk import of the prestaged content on the remote Distribution Point put all PKGX files in the same folder and then run this one line command:

for /r c:\temp %s in (*.pkgx) do extractcontent /P:%s /S

A couple of important notes at the end:

  1. By default SCCM Powershell execution policy is set to AllSigned and cannot be reset to Unrestricted using Set-ExecutionPolicy. If you run a script set it to RemoteSigned.
  2. SCCM Powershell does not execute scripts outside SCCM environment. If you change SCCM Powershell to any local drive your script would not execute.

How to export SCCM 2012 ADR

May 11th, 2015

How to export SCCM 2012 Automatic Deployment Rule?

1. Start SCCM 2012 PowerShell core by clicking on the down arrow in the left upper corner of SCCM 2012 Management Console – Connect via Windows PowerShell.

2. Use Get-CMSoftareUpdateAutoDeploymentRule to display all rules or Get-CMSoftareUpdateAutoDeploymentRule -Name “<rule name>” to display a specific rule.

3. Format output and/or redirect it to a file

Serge Chegorian's System Center Blog

Serge Chegorian's System Center Blog