Manage Distribution Point Content Using PSCMContentMgmt

Adam CookEndpoint Management, MECM/MEMCM/SCCM, Powershell, ScriptingLeave a Comment


I recently wrote PSCMContentMgmt which provides a simple and effective workflow for managing your MEMCM distribution points. Here are some of the things you can do with it:

  • Query content objects which are distributed to distribution point(s) or distribution point group(s)
  • Compare content objects distributed to distribution point(s) or distribution point group(s)
  • Find content objects in a “distribution failed” state for all or selective distribution points
  • Remove, distribute or redistribute content objects returned by any function to distribution point(s)
  • Find an object in your site by searching on any arbitrary ID (useful when reading logs and want to know what object an ID resolves to)
  • Migrate a distribution point’s content to a new/different distribution point by exporting its content library to prestaged .pkgx files and importing the .pkgx files to the new distribution point
  • Invoke the ContentLibraryCleanup.exe tool

PSCMContentMgmt is a mix of being no more than a wrapper for MEMCM cmdlets or native binaries. Some functions query WMI or invoke WMI methods.

PSCMContentMgmt does not intend to reinvent the wheel from already available cmdlets. Instead it provides a simpler workflow for managing your distribution points by offering:

  • Easy to use pipeline support, so you can easily progress through the motions for tasks such as querying content on a distribution point or distribution point group – perhaps in a particular state (e.g. “distribution failed”) – and distributing, redistributing or removing it from another (or the same) distribution point or distribution point group.
  • Consistent property names when dealing with different types of content objects, i.e. the ObjectID property is always PackageID except for Applications/Deployment Types where it is CI_ID (same is true for the -ObjectID parameter on functions that offer it).
  • Functionality which the Configuration Manager console does not provide e.g. content redistribution or import .pkgx files.

At the time of writing this, here are a list of functions in PSCMContentMgmt (be sure to check out the docs on the GitHub repository in case there are changes):


Install the module from the PowerShell gallery and import it to your session:

PS C:\> Install-Module PSCMContentMgmt -Scope CurrentUser
PS C:\> Import-Module PSCMContentMgmt

Each function will have two parameters to communicate to your environment with:

  • -SiteServer: the FQDN server address of your site server (SMS Provider)
  • -SiteCode: the site code of the environment

Using these parameters once for any function of PSCMContentMgmt enables you to not specify them again. These values are held in memory for as long as the PowerShell session exists.

In other words, if you used Get-DP and passed the parameters -SiteServer and -SiteCode, you do not need to specify them again in subsequent uses of Get-DP, and any other function of PSCMContentMgmt.

If the first function you use after importing PSCMContentMgmt requires -SiteServer and -SiteCode and you have not passed the parameters, you will be prompted for them.

If you want to change the values of -SiteServer or -SiteCode, pass those parameters again for any function and those new values will be used for subsequent calls.

This is intended to provide a fluid user experience where you need not to repeatedly specify these required parameters while using the module interactively. You will notice using Get-Help on any functions of PSCMContentMgmt will indicate these parameters are not mandatory. However the user experience will indicate otherwise. This design choice, which favours user experience, does sacrifice the discoverability of these parameter’s mandatory requirement.

Where any of the functions return an object with the property ObjectID, or where a parameter is named -ObjectID, it will always be the PackageID for all content objects (Packages, Driver Packages, Boot Images etc) except for Applications/Deployment Types where it is CI_ID. This enables you to have a property ready to use for Applications with any of the cmdlets from the Configuration Manager module.


I’ll walk you through some key examples which I think most people will benefit from.

Comparing distributed content objects between two distribution points or distribution point groups

PS C:\> Compare-DPContent -Source "" -Target ""

ObjectName        : 2020-03-1809
Description       :
ObjectType        : DeploymentPackage
ObjectID          : ACC000F3
SourceSize        : 324981
DistributionPoint :

ObjectName        : 2020-02-1809
Description       :
ObjectType        : DeploymentPackage
ObjectID          : ACC000F4
SourceSize        : 292894
DistributionPoint :


Returns content objects which are on but not

With this command, you can pipe it to other appropriate functions within PSCMContentMgmt, e.g. Remove-DPContent or Start-DPContentDistribution.

PS C:\> Compare-DPContent -Source "" -Target "" | Start-DPContentDistribution -DistributionPoint ""

Result    ObjectId ObjectType               Message
------    -------- ----------               -------
Success   ACC00001 Package
Success   ACC00004 BootImage
Success   ACC00005 BootImage
Success   ACC00007 Package
Success   16999742 Application
Success   16999646 Application
Success   16999674 Application
Success   16999752 Application
Success   16999720 Application
Success   17007034 Application


Finding content objects in “distribution failed” state and initiating redistribution en masse

This is the most practical function I like about PSCMContentMgmt. It is not uncommon for me to experience distribution failures in my environments and I wanted a way to quickly have a visual on those, and take action.

PS C:\> Get-DP | Get-DPDistributionStatus -DistributionFailed | Group-Object -Property DistributionPoint

Count Name                      Group
----- ----                      -----
   42           {@{ObjectID=17099179; ObjectType=Applicat...
   30	        {@{ObjectID=17099179; ObjectType=Applicat...

Return all distribution points, their associated failed distribution tasks and group the results by distribution point name for an overview.

PS C:\> Get-DPDistributionStatus -DistributionPoint "" -DistributionFailed | Start-DPContentRedistribution

This is an example on taking action on those items. In this instance, I’m initiating redistribution for all of the objects on in a “distribution failed” state.

If you didn’t want to redistribute, you could pipe to Remove-DPContent instead.

Finding objects in your environment with some arbitrary ID

This is my favourite function. Do you ever look through log files, see some random ID that you know represents some object in console and just want to know what object that is?

Find-CMObject accepts one parameter and that’s -ID. Pass it anything and it’ll do its best to find these objects for you:

  • Applications
  • Deployment Types
  • Packages
  • Drivers
  • Driver Packages
  • Boot Images
  • Operating System Images
  • Operating System Upgrade Images
  • Task Sequences
  • Configuration Items
  • Configuration Baselines
  • User Collections
  • Device Collections
  • (Software Update) Deployment Packages
PS C:\> Find-CMObject -ID "ACC00048"

Finds any object which has the PackageID “ACC00048”, this includes Applications, collections, driver packages, boot images, OS images, OS upgrade images, task sequences and deployment packages.

It searches for Applications by PackageID as a last resort if no match has been found yet by loading every Application’s PackageID property which is a lazy property in WMI. This can be time consuming, depending on how many Applications you have in your site, hence why it is last in the list.

Migrating a distribution point to another

Do you need to stand up a new distribution point beside an existing one, but don’t want to send content across the WAN?

This requirement was what originally inspired me to write the module. A couple of years ago I came across this post by someone with the handle SYN_ACK_87. The code offered on TechNet helped me hugely at the time for what I needed, but I felt like adding extra bits. I rolled my own and here we are.

Pull distribution points are undoubtedly a million miles easier than this. If you can, or do currently, use pull distribution points, don’t follow this. Configure the new distribution point to pull from the old distribution point.

However if for whatever reason you can’t or don’t want to use the pull distribution point method, then this is for you.

1. Begin by exporting your old/source distribution point’s content using Export-DPContent.

Preferably this server will be on the same LAN as the distribution point you intend to import the .pkgx files to.

If the server is remote across a slow link, it is recommended you copy the .pkgx files generated by Export-DPContent to your new/target distribution point.

PS C:\> Get-DPContent -DistributionPoint "" | Export-DPContent -Folder "E:\exported"
2. Configure your new/target distribution point to allow prestaged content using Set-DPAllowPrestagedContent.

This will ensure when we use Start-DPContentDistribution in the next step that the content will not inadvertently transfer across an undesired route.

PS C:\> Set-DPAllowPrestagedContent -DistributionPoint ""
3. Distribute the exported content from step 1 using Start-DPContentDistribution using its -Folder parameter.

This will walk through all .pkgx files in the given folder, identifying each object by the particular naming convention of the .pkgx files generated by Export-DPContent, and distribute each of the objects they represent in console to your new/target distribution point.

This will put the content objects in console in a “Pending” state; waiting to be imported on your new/target distribution point.

Start-DPContentDistribution -Folder "E:\exported" -DistributionPoint ""
4. Log on locally or enter a PowerShell session to your new/target distribution point and import PSCMContentMgmt to run Import-DPContent.

This step must be executed locally to your new/target distribution point. This is because Import-DPContent simply invokes ExtractContent.exe.

Use Import-DPContent and the -Folder parameter (which is preferably a local drive path, or a UNC path where the host is on the same LAN) to begin importing content.

Similar to step 3, Import-DPContent depends on the particular naming convention of .pkgx files generated by Export-DPContent to successfully import the content.

PS C:\> Import-DPContent -Folder "\\\e$\exported"
5. Unconfigure your new/target distribution point to only allow prestaged content.
PS C:\> Set-DPAllowPrestagedContent -DistributionPoint "" -State $false

Getting help

If you’re seeing or hearing things, I recommend you drink more rum.

I encourage you to read the documentation on the GitHub repository page and the Get-Help material. I wrote several “About” help topics , filling all functions with examples and detailed descriptions for parameters.

To view the help material for a particular function:

PS C:\> Get-Help Compare-DPContent -Detailed

To see all of the “About” help topics available for PSCMContentMgmt:

PS C:\> Get-Help about_PSCMContentMgmt*

To read one of the “About” help topics:

PS C:\> Get-Help about_PSCMContentMgmt_Query

Failing that:

  • If you think you’re experiencing, or have found, a bug in PSCMContentMgmt, please open an issue on its GitHub repository.
  • Ping me on Twitter @codaamok.
  • Come to the WinAdmins Discord and bug me there, my handle is @acc.

The Configuration Manager module notoriously returns generic error messages (if any) for most of its cmdlets/functions. Since this module is mostly nothing more than a wrapper for most cmdlets/functions, I just forward those messages on to you so please bear that in mind.

Leave a Reply

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