Hi All,
I needed a basic script to backup my task sequences on a schedule. Using PowerShell to back up your Task Sequences is a much faster way than manually doing it through the console.
See below code:
<# | |
.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 | |
} | |
Save the code above to a ps1 file, put on your SCCM server and set up a scheduled task to run the following command: powershell.exe -executionpolicy bypass -file “file.ps1”
How large do these backups get? Is everything compressed?
LikeLike
Take a look at the file sizes in the photo, uses no memory at all. They are all zipped.
LikeLike