Skip to content

Instantly share code, notes, and snippets.

@danjpadgett
Last active Aug 14, 2017
Embed
What would you like to do?
<#
.SYNOPSIS
Backup all task sequences to disk greater than $minDate
.DESCRIPTION
TS backup will fail if TS name has special characters not allowed, edit sitecode and destinationpath
.PARAMETER <Parameter_Name>
None
.INPUTS
None
.OUTPUTS
None
.NOTES
Version: 4.0
Author: dpadgett/https://execmgr.net
Creation Date: 270617
Purpose/Change: Initial script development
.EXAMPLE
None
#>
##Modify ConfigMgr Path if necessary##
Import-Module 'D:\Program Files\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1'
##Enter Site Code Below###
CD XXX:
[datetime]$minDate = "1/1/2017 00:00:00 AM"
$ts = Get-CMTaskSequence | Where-Object {$_.SourceDate -gt $minDate}
$time = get-date -format ddMMyyyy
New-Item -Path "E:\Source\ITS\TSBackups\Backups\$time" -ItemType Directory
foreach ($t in $ts){
$path = "E:\Source\ITS\TSBackups\Backups"
$exportname = $t.Name
Export-CMTaskSequence -TaskSequencePackageId $t.PackageID -ExportFilePath "$path\$time\$exportname.zip" -Verbose
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment