ConfigMgr

VMware, Azure and Automation

Restoring Task Sequences the easy way

7 mei 2017 ConfigMgr SCCM Script Solutions

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

Recent Posts

  • Using API for Aria OPS Chargeback
  • Unable to set reservation on Org VDC
  • Veeam Tweaks
  • VCF Anyone? Get your license for free…
  • Configure Entra ID as Cloud Director IdP

Recent Comments

Geen reacties om te tonen.

Archives

  • april 2025
  • maart 2025
  • november 2024
  • oktober 2024
  • januari 2024
  • november 2023
  • oktober 2023
  • september 2023
  • juni 2023
  • mei 2023
  • april 2023
  • november 2022
  • maart 2021
  • februari 2021
  • januari 2021
  • november 2020
  • oktober 2020
  • september 2020
  • juli 2020
  • juni 2020
  • april 2020
  • maart 2020
  • februari 2020
  • oktober 2019
  • september 2019
  • juli 2019
  • juni 2019
  • mei 2019
  • maart 2019
  • februari 2019
  • januari 2019
  • december 2018
  • november 2018
  • april 2018
  • januari 2018
  • juli 2017
  • juni 2017
  • mei 2017

Categories

  • AnyLinq
  • Azure
  • Cloud Director
  • ConfigMgr
  • DIY
  • HomeAssistant
  • Microsoft
  • PowerCli
  • Powershell
  • SCCM
  • Script
  • Solutions
  • System Center
  • Veeam
  • VMware
  • vRealize Automation
  • vRealize Orchestrator
Proudly powered by WordPress | Theme: Doo by ThemeVS.