How to show OOBE for AzureAD Join after OSD with SCCM

Updated 2021-06-09
– Added some additional cleanup in the script to make sure it removes the CM client, otherwise the computer will be “co-managed” in Intune even if it isn’t. Also added info about the SkipOOBE in unattend.xml

I am writing this post because I am lazy and already have Configuration Manager in my lab. But it is useful in other scenarios as well to get the latest version of Windows 10 on a computer before testing AzureAD Join/Autopilot for example. It is also useful in Self-deploying Autopilot scenarios which isn’t supported by the existing Autopilot Task sequence for existing devices.
When I am testing more and more scenarios with AzureAD Join and Autopilot I ended up doing this little workaround to be able to deploy Windows 10 using Configuration Manager, uninstall the SCCM client and then reboot the machine and come up in OOBE.

Fellow MVP Per Larsen wrote a blog post on how to do it with MDT a while back which is great, if you use MDT have a look at it https://osddeployment.dk/2016/08/26/how-to-show-oobe-for-azuread-join-after-mdt-deployment/

I use a little Powershell script that uninstalls the SCCM client and then run Sysprep on the machine which I trigger using the SMSTSPostAction command.

Sample SMSTSPostaction

The PowerShell script. In this example I use /OOBE as the computer is newly deployed, then it will keep the computername we assigned during OSD. I we change it the command to include /Generalize then it will of course not keep the name and generalize the installation again.

Start-Process -FilePath "C:\Windows\ccmsetup\ccmsetup.exe" -ArgumentList "/Uninstall"
Start-Sleep -Seconds 60
Wait-Process -Name "ccmsetup" -ErrorAction SilentlyContinue
Remove-Item -Path HKLM:\SOFTWARE\Microsoft\CCM -Recurse -Force -EA SilentlyContinue
Remove-Item -Path HKLM:\SOFTWARE\Microsoft\CCMSetup -Recurse -Force -EA SilentlyContinue
Remove-Item -Path HKLM:\SOFTWARE\Microsoft\SMS -Recurse -Force -EA SilentlyContinue
Remove-Item -Path C:\Windows\CCM -Recurse -Force -EA SilentlyContinue
Remove-Item -Path C:\Windows\CCMCache -Recurse -Force -EA SilentlyContinue
Remove-Item -Path C:\Windows\CCMSetup -Recurse -Force -EA SilentlyContinue
Remove-Item -Path C:\Windows\SMSCFG.ini -Force -EA SilentlyContinue
Remove-item -Path C:\Windows\sms*.mif -Force -EA SilentlyContinue
Start-Process -FilePath "C:\windows\system32\sysprep\sysprep.exe" -ArgumentList "/oobe"

I created a package of the script and added a small file called copy.cmd file to copy the PowerShell script to C:\Windows\temp so it can be executed from there.

Script folder

I run the script the last thing I do and then I let the SMSTSPostAction execute the script.

Copy cleanup script samples step

NOTE: the “Apply operating System” step must include an unattand.xml file which includes SkipOOBE otherwise our SMSTSPostaction will fail.

Apply Operating System step
SkipMachineOOBE in unatted.xml


The end result is as expected a Windows 10 machine in OOBE and can be AzureAD Joined.

OOBE

It saved me time when testing AzureAD Join and Autopilot in my lab, with different versions of Windows 10. I hope it will save you time as well.

19 Comments

Add a Comment

Your email address will not be published. Required fields are marked *

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