Windows PowerShell Examples for Content Management
Published Sep 07 2018 10:47 PM 500 Views
First published on CloudBlogs on Nov, 13 2013


This article covers some basic content management usage scenarios using Windows PowerShell for System Center 2012 R2 Configuration Manager.  Included are examples on how to create a site system and configure it as a distribution point (including pull-distribution points), and how to create and distribute content.

This article assumes some basic familiarity with Windows PowerShell in general and good knowledge of content management in System Center 2012 R2 Configuration Manager.

Starting Windows PowerShell with Configuration Manager Cmdlets

To start a Windows PowerShell session and automatically load Configuration Manager cmdlets, in the Configuration Manager console, click the blue drop-down menu in the top left, and click Connect via Windows PowerShell .  This will start a Windows PowerShell session and automatically load the Configuration Manager cmdlets.

An important cmdlet to take note of is the Get-Help cmdlet, which will give an overview of cmdlet parameters and values.  For example:

Get-Help Add-CMDistributionPoint

This will show the required and optional parameters, input types, etc.  Most parameters are self-explanatory given an understanding of content management in Configuration Manager.

If you have not yet downloaded updateable help, use the Update-Help cmdlet to install the latest Configuration Manager cmdlet help. You must open the Windows PowerShell console as Administrator to perform this operation.

Site Server and Distribution Point Management

First, let us create a site system server on the site ‘ABC’ (later we will configure it as a distribution point), using the site server’s computer account.

New-CMSiteSystemServer –SiteCode ‘ABC’ –UseSiteServerAccount –ServerName ‘’

Next, we will configure it as a distribution point.  We will create a self-signed certificate that expires on January 1, 2015 at 1:00 AM.  The distribution point will reserve 100 MB of free space on the drive after content is stored.  IIS will be installed.  PXE will be enabled and the distribution point will respond to incoming PXE requests, without requiring a password.

Add-CMDistributionPoint –SiteCode ‘ABC’ –SiteSystemServerName ‘’ –CertificateExpirationTimeUtc ‘1/1/2015 1:00 AM’ –MinimumFreeSpaceMB 100 –InstallInternetServer –EnablePxeSupport -AllowRespondIncomingPxeRequest

Windows PowerShell loops can be used to configure multiple distribution points with one command.  This loop will create two more distribution points, and, with the same settings.

$dpServerNames = ‘dp2’,‘dp3’;
$domainSuffix = ‘’;

foreach ($dpServerName in $dpServerNames)


$dpFQDN = $dpServerName + ‘.’ + $domainSuffix;

Add-CMDistributionPoint –SiteCode ‘ABC’ –SiteSystemServerName $dpFQDN –CertificateExpirationTimeUtc ‘1/1/2015 1:00 AM’ –MinimumFreeSpaceMB 100 –InstallInternetServer –EnablePxeSupport –AllowRespondIncomingPxeRequest;


Now, let us configure as a pull-distribution point, also using the same settings as above.  We'll use the first three distribution points from above as source distribution points, preferring (rank 1), then (rank 2), then (rank 3).

Add-CMDistributionPoint –SiteCode ‘ABC’ –SiteSystemServerName ‘’ –CertificateExpirationTimeUtc ‘1/1/2015 1:00 AM’ –MinimumFreeSpaceMB 100 –InstallInternetServer –EnablePxeSupport –AllowRespondIncomingPxeRequest –EnablePullDP –SourceDistributionPoints ‘’,‘’,‘’ –SourceDPRanks 1,2,3

Distribution Point Group Management

First, we will create a new distribution point group, called ‘ABC Distribution Points’.

New-CMDistributionPointGroup –Name ‘ABC Distribution Points’

Now, we will add all four of our distribution points to the distribution point group.  We can use a loop, as above, to accomplish this in one command.

$dpServerNames = ‘dp1’,‘dp2’,‘dp3’,‘dp4’;
$domainSuffix = ‘’;

foreach ($dpServerName in $dpServerNames)


$dpFQDN = $dpServerName + ‘.’ + $domainSuffix;

Add-CMDistributionPointToGroup –DistributionPointName $dpFQDN –DistributionPointGroupName ‘ABC Distribution Points’;


We will also add the device collection ‘All Desktop and Server Clients’ to the distribution point group.  When packages and applications are deployed to this collection, they will be automatically distributed to the distribution point group.  Alternatively, the collection can be named as a target for distribution, and the content will be distributed to the members of the distribution point group.

Add-CMDeviceCollectionToDistributionPointGroup –DeviceCollectionName ‘All Desktop and Server Clients’ –DistributionPointGroupName ‘ABC Distribution Points’

Boundary Group Management

Boundary groups are used to control which distribution points a client uses to download the content.  Let’s add all four of our distribution points to an existing boundary group named ‘ABC Client Boundary Group’, which contains all Configuration Manager clients for the site ‘ABC’.

$dpServerNames = ‘dp1’,‘dp2’,‘dp3’,‘dp4’;
$domainSuffix = ‘’;

foreach ($dpServerName in $dpServerNames)


$dpFQDN = $dpServerName + ‘.’ + $domainSuffix;

Set-CMDistributionPoint –SiteCode ‘ABC’ –SiteSystemServerName $dpFQDN –AddBoundaryGroupName ‘ABC Client Boundary Group’;


Note:  the AddBoundaryGroupName parameter is currently only available for the Set-CMDistributionPoint cmdlet, not for the Add-CMDistributionPoint cmdlet.  This is a known issue and will be addressed in future releases.

Content Creation

First we will create a package (and associated program) for desktop and server clients.  Let's assume that all of our package files exist in the network share \primarysite.contoso.comProgramsPackage01 .  Also assume that there is a batch script, Package01.bat , which will perform necessary actions.

New-CMPackage –Name ‘Example Package with Program’ –Description ‘This is an example package’ –Path ‘\primarysite.contoso.comProgramsPackage01’

We will assume the ID for the created package is ABC00001.  Next, we need to create a program for the package, based on the batch file.  Some optional parameters are included:  It will run hidden regardless of whether users are logged in, using administrator rights.  Many more options are available, and can be found by using the Get-Help cmdlet.

New-CMProgram –PackageName ‘Example Package With Program’ –StandardProgramName ‘Example Program’ –CommandLine ‘Package01.bat’ –RunType Hidden –ProgramRunType WhetherOrNotUserIsLoggedOn –RunMode RunWithAdministrativeRights

Let us assume we have created another very similar package, which has an ID of ABC00002.

Next, we will create an application.

New-CMApplication –Name ‘Contoso Tools’ –ReleaseDate ‘6/1/2013 12:00 PM’ –AutoInstall 0 –Description ‘Tools for Contoso employees’

Next, we’ll add a few deployment types.  Let’s assume we have 64-bit and 32-bit versions of the tools.

Add-CMDeploymentType –ApplicationName ‘Contoso Tools’ –MsiInstaller –AutoIdentifyFromInstallationFile –InstallationFileLocation ‘\primarysite.contoso.comApplicationscontoso_tools_x64.msi’ –ForceForUnknownPublisher 1

Add-CMDeploymentType –ApplicationName ‘Contoso Tools’ –MsiInstaller –AutoIdentifyFromInstallationFile –InstallationFileLocation ‘\primarysite.contoso.comApplicationscontoso_tools_x86.msi’ –ForceForUnknownPublisher 1

Content Distribution

Next, we will distribute the package ABC00001 to the device collection ‘All Desktop and Server Clients’, which will distribute it to the distribution point group ‘ABC Distribution Points’, and package ABC00002 directly to the group.  We will distribute the application named ‘Contoso Tools’ to only

Start-CMContentDistribution –PackageId ‘ABC00001’ –CollectionName ‘All Desktop and Server Clients’

Start-CMContentDistribution –PackageID ‘ABC00002’ –DistributionPointGroupName ‘ABC Distribution Points’

Start-CMContentDistribution –ApplicationName ‘Contoso Tools’ –DistributionPointName

Content Deployment

We will begin by deploying our first package and program to all desktop and server clients.

Start-CMPackageDeployment –PackageId ‘ABC00001’ –StandardProgramName ‘Example Program’ –CollectionName ‘All Desktop and Server Clients’ –ScheduleEvent AsSoonAsPossible –RerunBehavior AlwaysRerunProgram –SystemRestart 0 –FastNetworkOption DownloadContentFromDistributionPointAndRunLocally –SlowNetworkOption DownloadContentFromDistributionPointAndLocally

Finally, we will deploy our application.

Start-CMApplicationDeployment –CollectionName ‘All Desktop and Server Clients’ –Name ‘Contoso Tools’ –DeployAction Install –DeployPurpose Required –DeadlineDate ‘1/1/2015’ –DeadlineTime ‘12:00 AM’ –UserNotification HideAll –RebootOutsideServiceWindow 1

Deployment Monitoring

The status of the deployment can be monitored as well.  Deployments to a specific collection can be found by specifying the collection name, for example, the device collection ‘All Desktop and Server Clients’.

Get-CMDeployment –CollectionName ‘All Desktop and Server Clients’

Listed will be various information about the deployment, including the time, deadline, package or application ID, and number of successful clients, in-progress clients, targeted clients, etc.  If information about a specific deployment is desired, the deployment ID can be found by using the above command and looking through to find the deployment.  The deployment ID is also shown when the deployment is started (see Content Deployment section above).

Once you have obtained the deployment ID, you can query for information on just that deployment.

Get-CMDeployment –DeploymentID ‘ABC20001’

-- Brandon Waterloo

This posting is provided "AS IS" with no warranties and confers no rights.

Version history
Last update:
‎Sep 07 2018 10:47 PM
Updated by: