Backup Task Sequences SCCM

Let me share with you a useful PowerShell script which allows you to back up your task sequences according to your trigger.
The following script knows export all task sequence and saves them as “*.ZIP” file, the Zip files contain all task sequence data.
Apparently, you are asking why should we run this PowerShell if we already have daily / weekly base backup to SCCM?
Very simple, at that moment that recovery task sequence will be needed you will try to restore full SCCM backup, which has huge impacts.
Why are you supposed to lose new DDR, Applications, any new data only because of 1 task sequence? sound ridiculous and irresponsible deed.

Of course, there are a couple of solutions you can find, whether is restore the task sequence from SQL [You have to be SQL expert], or restore the SCCM to other LUN and then retrieve the stated TS, but it may take some time.
Therefore, I suggest to run this PS script as once a week and sleep well

cd D:\Program Files\Microsoft Configuration Manager\AdminConsole\bin Import-Module .\ConfigurationManager.psd1 $sitecode = Get-PSDrive -PSProvider CMSite Set-Location -path "$($sitecode.Name):\" $backup = Get-CMTaskSequence | select name foreach($name1 in $backup) { Export-CMTaskSequence -Name $name1.name -ExportFilePath ("\\server-sccm\TS Backup\"+$name1.name + ".zip") } $a = Get-Item ("D:\TS Backup\" + $name1.name + ".zip") if ($a.LastWriteTime.Date -eq (Get-Date).Date) { Send-MailMessage -to "[email protected]" -From "[email protected]" -Subject "SCCM Backup" -Body "Backup ok" -SmtpServer "xxxx" } else { Send-MailMessage -to "[email protected]" -From "[email protected]" -Subject "SCCM Backup" -Body "Backup failed" -SmtpServer "xxxx" }