SCCM: Copy all task sequence deployments to another task sequence

2 min read

I will show you how to:

  1. Get all the collections that a task sequence is deployed to
  2. Apply a consistent set of deployment settings to those collections for a different task sequence

… using PowerShell.

This ensures consistent settings are used for all deployments and that a task sequence is deployed to all the same collections as per the old task sequence. The biggest benefits are to eliminate human error and not spend time on a repetitive and tedious process.

All of the deployments for the new task sequence will have an assignment date and availability date set 1 year ahead from the point of which you run the below. This ensures the clients don’t immediately action on the new policy or begin downloading the content before the date, giving you time to review/stagger each deployment. I don’t think the clients would start downloading the content because in the below I’ve configured it to be only available to PXE and media, so I could have omitted the assignment schedule config, but I wasn’t 100% sure so I thought better to be safe than sorry. If your task sequence is deployed to be available to configuration manager clients also, I would definitely keep this in.

There’s also an exclusion list that may be useful for you.

It’s not by any means a work of art, but it got the job done.

Perhaps I could write a variant of this that mimics not just all the deployed collections of a given task sequence but also carry over the deployment settings too, rather than blanketing them all with one config.

  1. Update variables $taskSequenceId_old, $taskSequenceId_new and $collectionIds_exclude
  2. Configure New-CMTaskSequenceDeployment to how you want it
$taskSequenceId_old = "XXX00001"
$taskSequenceId_new = "XXX00002"

$collectionIds = (Get-CMTaskSequenceDeployment -TaskSequenceId $taskSequenceId_old).CollectionId 
$collectionIds_exclude = "XXX0001A","XXX0001B","XXX0001C"

$date = (Get-Date).AddYears(1) 
$CMSchedule = New-CMSchedule -Start $date -Nonrecurring 

ForEach ($collection in $collectionIds | ? { $collectionIds_exclude -notcontains $_ }) { 
    New-CMTaskSequenceDeployment -TaskSequencePackageId $taskSequenceId_new -CollectionId $collection -Comment "Created by user $($env:username) on $((Get-Date).ToString())" -DeployPurpose "Required" -Availability "MediaAndPxe" -UseUtcForAvailableSchedule $false -Schedule $CMSchedule -RerunBehavior "RerunIfFailedPreviousAttempt" -ShowTaskSequenceProgress $true -SoftwareInstallation $true -SystemRestart $true -InternetOption $false -DeploymentOption "DownloadContentLocallyWhenNeededByRunningTaskSequence" -AllowSharedContent $false -AllowFallback $false -AvailableDateTime $date -UseMeteredNetwork $false -PersistOnWriteFilterDevice $true -SendWakeupPacket $false 
}
Last Updated on