MEM or SCCM: Copy/clone content between distribution points

Decorative title image PowerShell and Microsoft SCCM logos with servers and arrows representing content cloning between them

All product names, logos, and brands used in this post are property of their respective owners.

If you have replaced a Microsoft Endpoint Manager distribution point (or scaled out by adding additional DPs to your topology), you may have needed to copy all content from an existing DP to a new one. By content, I am referring to Applications, Packages, Boot Images, Operating System Images, Driver Packages, etc. If you had not guessed, I recently encountered that exact scenario.

At the time of writing, I could not find a quick, native way to achieve that type of content cloning. Configuration Manager PowerShell to the rescue!

First, connect using the Microsoft Endpoint Manager PowerShell module:

Screenshot demostrating the “Connect via Windows PowerShell” option under the dropdown menu in the top left corner of the Configuration Manager console interface

Then, copy/paste the snippet below (or from my Gist), update the $sourceDP and $destDP variables accordingly, and let it rip! Depending on the content volume on your source distribution point, network conditions, etc., you will eventually have all content from your source DP available on your destination distribution point.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# Specify the FQDNs of the source and destination distribution points
$sourceDP =  "MEMCMDP1.contoso.com"
$destDP = "MEMCMDP2.contoso.com"

# Suppress error messages (usually because content already exists on the destination)
$ErrorActionPreference = "SilentlyContinue"

# Get all content from the source DP
# See https://learn.microsoft.com/en-us/powershell/module/configurationmanager/get-cmdeploymentpackage?view=sccm-ps
Get-CMDeploymentPackage -DistributionPointName $sourceDP | %{
	[int]$currentContentObjectTypeID = $_.ObjectTypeID
	$currentContentID = $_.PackageID
	$currentContentName = $_.Name
	# Use ObjectTypeID identify the type of content
	# See https://learn.microsoft.com/en-us/mem/configmgr/develop/reference/core/servers/console/sms_objectcontentinfo-server-wmi-class
	# Then, start distribution of the content to the destination DP
	# See https://learn.microsoft.com/en-us/powershell/module/configurationmanager/start-cmcontentdistribution?view=sccm-ps#-inputobject
	switch($currentContentObjectTypeID) {
		2 { Get-CMPackage -Id $currentContentID | Start-CMContentDistribution -DistributionPointName $destDP }
		14 { Get-CMOperatingSystemInstaller -Id $currentContentID | Start-CMContentDistribution -DistributionPointName $destDP }
		18 { Get-CMOperatingSystemImage -Id $currentContentID | Start-CMContentDistribution -DistributionPointName $destDP }
		19 { Get-CMBootImage -Id $currentContentID | Start-CMContentDistribution -DistributionPointName $destDP }
		21 { }
		23 { Get-CMDriverPackage -Id $currentContentID | Start-CMContentDistribution -DistributionPointName $destDP }
		24 { Get-CMSoftwareUpdateGroup -Id $currentContentID | Start-CMContentDistribution -DistributionPointName $destDP }
		31 { Get-CMApplication -Name $currentContentName | Start-CMContentDistribution -DistributionPointName $destDP }
	}
}

I hope this short post helps someone with a similar requirement.