• About me…
  • VMware
  • Powershell
  • DIY

ConfigMgr.nl

VMware, PowerShell, Automation, and more…

  • About me…
  • VMware
  • Powershell
  • DIY

Restoring Task Sequences the easy way

7 mei 2017 ConfigMgr SCCM Script Solutions No Comments

A while ago I was asked if it was possible to restore a Task Sequence. My first reaction was “of course”. But digging into the problem I quickly realized I would need to restore the entire ConfigMgr database. And because it was a primary site under a CAS I was a bit reluctant. The immediate need for the restore went away but it made me think of a more easy way of restoring a Task Sequence. This is what I came up with.

The backup of the database is being done from within SQL Server with a maintenance plan. I already added a SQL Agent Job to this Maintenance Plan so what if I could add a second job to create an export of all the excisting Task Sequences?

The first step was to create the code to export all Task Sequences.

[code language=”powershell”]
import-module ($Env:SMS_ADMIN_UI_PATH.Substring(0,$Env:SMS_ADMIN_UI_PATH.Length-5) + ‘\ConfigurationManager.psd1’)
Set-Location CM0:
Foreach ($ts in Get-CMTaskSequence) {
$ZipName = "\\server\share$\task-sequences\" + $ts.Name + ".zip"
Export-CMTaskSequence -Name $ts.Name -ExportFilePath $ZipName
}
[/code]

Then add this code as a Powershell script to a SQL Agent Job. Make sure that the service account that is running the SQL job has appropiate permissions in ConfigMgr.

To make it work I had to logon to the ConfigMgr console once with the SQL service account. This makes sure that all registry keys are there…

Now everytime that my SQL backup runs it also makes a zip file of every Task Sequence. Include the folder in your file level backup to add retention because the Export-CMTaskSequence cmdlet will overwrite existing zip files.

You could also use WMI Event Scripting to create a backup everytime a Task Sequence is changed… But that is something for the future.

Creating Azure JSON templates with Visual Studio Code

Powershell - looking up HP warranty information

Geef een reactie Antwoord annuleren

Deze website gebruikt Akismet om spam te verminderen. Bekijk hoe je reactie-gegevens worden verwerkt.

Meest recente berichten

  • Handy one-liners
  • The system has insufficient locker space for the image profile
  • Testing Script Runtime Service for vSphere – part 2
  • Reporting on your Windows Server backup
  • Testing Script Runtime Service for vSphere – part 1

Jeroen BurenFollow

Jeroen Buren
jeroen_burenJeroen Buren@jeroen_buren·
15 apr

Had some spare time... So I did the HCI Master Specialist Exam and nailed it ;-) #vExpert #VMware #HCI

Reply on Twitter 1382574365389258752Retweet on Twitter 1382574365389258752Like on Twitter 138257436538925875220Twitter 1382574365389258752
jeroen_burenJeroen Buren@jeroen_buren·
15 apr

Join VMware's global event on May 5th & 6th to see their strategy for the new distributed workforce. There will be 13 technical sessions on @WorkspaceONE and @vmwarehorizon, @VMwareSDWAN, @vmw_carbonblack, and more! https://www.vmware.com/anywhere-workspace-event.html?src=so_6075a9bbde44b&cid=7012H000001l6vL #AnywhereWorkspace

Reply on Twitter 1382569804020744192Retweet on Twitter 1382569804020744192Like on Twitter 13825698040207441922Twitter 1382569804020744192
jeroen_burenJeroen Buren@jeroen_buren·
10 apr

Go #XRP Go... To infinity and beyond!

Reply on Twitter 1380903963772469253Retweet on Twitter 1380903963772469253Like on Twitter 13809039637724692531Twitter 1380903963772469253
jeroen_burenJeroen Buren@jeroen_buren·
10 apr

En weer 3 minuten kou geleden...

Reply on Twitter 1380801147368304640Retweet on Twitter 1380801147368304640Like on Twitter 13808011473683046401Twitter 1380801147368304640
jeroen_burenJeroen Buren@jeroen_buren·
5 apr

Het wordt nu toch echt lente!! 😂 #SpringTime

Reply on Twitter 1379101934813114375Retweet on Twitter 1379101934813114375Like on Twitter 13791019348131143754Twitter 1379101934813114375
Load More...

Categorieën

Proudly powered by WordPress | Theme: Doo by ThemeVS.