• About me…

ConfigMgr.nl

VMware, Automation and more

  • About me…

Restoring Task Sequences the easy way

07-05-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.

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
}

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

Leave a Reply Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Recent Posts

  • Reporting on your Windows Server backup
  • Testing Script Runtime Service for vSphere – part 1
  • Using ADFS with vCenter 7
  • Network Port Diagram vSphere
  • Joining ESXi hosts to AD using Authentication Proxy in vCenter 7 (updated 04-12-2020)
  • Windows Server 2019 customization issue
  • Packer and WinRM – mystery resolved
  • Using LDAPS with vCenter and AD
  • Backup your homelab… for free!
  • Remediation did not succeed

Archives

Categories

AnyLinq (1) Azure (2) ConfigMgr (8) DIY (4) PowerCli (8) Powershell (9) SCCM (9) Script (12) Solutions (16) System Center (3) VMware (30) vRealize Automation (1) vRealize Orchestrator (1)

Jeroen BurenFollow

Jeroen Buren
Retweet on TwitterJeroen Buren Retweeted
Annemiek73Annemiek Meijer@Annemiek73·
16 Jan

Running man kan altijd! Ook tijdens #VVAL2021 @VriendvanAmstel #RunningMan #VVALS

Reply on Twitter 1350537030879608833Retweet on Twitter 13505370308796088332Like on Twitter 135053703087960883327Twitter 1350537030879608833
Retweet on TwitterJeroen Buren Retweeted
PowerCLIVMware PowerCLI@PowerCLI·
11 Jan

Do check out the SRS roadmap here. Feel free to influence the roadmap by submitting your requests. https://github.com/vmware/script-runtime-service-for-vsphere/projects/2 https://twitter.com/PowerCLI/status/1337370157551796225

VMware PowerCLI@PowerCLI

Introduction to Script Runtime Service (SRS) for vSphere https://blogs.vmware.com/PowerCLI/2020/12/introduction-to-script-runtime-service-srs-for-vsphere.html

Reply on Twitter 1348606798492618752Retweet on Twitter 13486067984926187524Like on Twitter 13486067984926187528Twitter 1348606798492618752
jeroen_burenJeroen Buren@jeroen_buren·
7 Jan

New blogpost about Script Runtime Service for vSphere.
https://configmgr.nl/2021/01/07/testing-script-runtime-service-for-vsphere-part-1/

#VMware #vSphere #SRS #PowerCLI

Reply on Twitter 1347191971002118144Retweet on Twitter 1347191971002118144Like on Twitter 1347191971002118144Twitter 1347191971002118144
jeroen_burenJeroen Buren@jeroen_buren·
18 Dec

Nice!! https://www.formula1.com/en/latest/article.breaking-perez-to-partner-verstappen-at-red-bull-in-2021-as-albon-becomes.21qHfmHAyfzAjVHT3PfVBd.html

Reply on Twitter 1339935240069001218Retweet on Twitter 1339935240069001218Like on Twitter 13399352400690012181Twitter 1339935240069001218
Retweet on TwitterJeroen Buren Retweeted
vRealizeAutovRealize Automation@vRealizeAuto·
16 Dec

#vRA x Terraform part 1 — #Cloud Automation Essentials☁️

Check out this blog to explore how you can use vRealize Automation and Terraform in effective ways.👍 https://bit.ly/3r2sLxE

Reply on Twitter 1339261564931727368Retweet on Twitter 13392615649317273686Like on Twitter 13392615649317273685Twitter 1339261564931727368
Load More...
Proudly powered by WordPress | Theme: Doo by ThemeVS.