Skip to content

Instantly share code, notes, and snippets.

@danjpadgett
Last active August 14, 2017 10:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danjpadgett/bc60b09e4e78880923df to your computer and use it in GitHub Desktop.
Save danjpadgett/bc60b09e4e78880923df to your computer and use it in GitHub Desktop.
<#
.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