Recover your Office 365 admin account

While studying for the 70-533 exam (which I passed) I purchased an Office 365 subscription and connected it to my Azure AD.  I added the domain name to Azure AD and also to Office 365.

After the exam I decided to clean up my Azure subscription and accidently deleted my Office 365 admin account…

So what to do? There are several articles about recovering accounts from Office 365 but they assume that you still have administrative access. And I didn’t.

First I tried to create a new user with the same username but that didn’t work. What did work was creating a new global administrator user with the same domain suffix and then recover the deleted user from the Office 365 admin center.

Restoring Task Sequences the easy way

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.