Menu
CCMEXEC.COM – Enterprise Mobility
  • Home
  • General
  • Configuration Manager
  • Windows 10
  • Intune
  • GitHub
  • Windows 11
  • About the author
CCMEXEC.COM – Enterprise Mobility

How to show OOBE for AzureAD Join after OSD with SCCM

Posted on September 25, 2018June 9, 2021 by Jörgen Nilsson

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.

  • Autopilot
  • OOBE
  • Self-deploying
  • 29 thoughts on “How to show OOBE for AzureAD Join after OSD with SCCM”

    1. Jonathan says:
      January 17, 2019 at 3:45 pm

      Hello I was wondering what the contents of copy.cmd is? and is there a way to just stop at SMSTSPostAction and delete the tasks at the bottom of that?

      Thanks!

      Reply
      1. Jörgen Nilsson says:
        January 18, 2019 at 3:58 pm

        Hi,
        It is simply
        copy /y “%~dp0prepareOOBe.ps1” “C:\Windows\Temp”
        Just to copy the Powershell script.
        Regards,
        Jörgen

        Reply
    2. Sander Noordijk says:
      March 14, 2019 at 11:51 am

      Thanks, worked like a charm! It does however leave the ccmsetup.exe and log file, but Autopilot didn’t recognize the device as SCCM maneged anymore so everything worked out.

      Reply
    3. Bob Wilkerson says:
      April 16, 2019 at 9:50 pm

      I confused about the task order. The copy.cmd is at the bottom and the task to run the PowerShell script is in the top series of tasks. Is this the correct order or should the PowerShell script be run after it is copied to the device.

      Reply
      1. Andrew Manning says:
        August 1, 2019 at 9:34 pm

        I’ve confused on this as well.
        Are they the right way round?

        Reply
        1. Evan Burt says:
          August 22, 2019 at 12:45 am

          This is correct. The call to the script itself is listed as a task sequence variable; SMSTSPostAction. This runs at the conclusion of the task sequence. In this case it’s the command to call the script via PowerShell. At the end of the task sequence (prior to SMSTSPostAction executing) the copy.cmd script runs and makes sure the PowerShell script is present.

          Reply
    4. Bob Wilkerson says:
      April 25, 2019 at 5:46 pm

      Do you have any information on the whole task sequence process? I would like to see the settings for each task in the whole sequence to make sure I am setting this up right? I have been struggling with using SCCM to deploy the image to my devices and get them joined to Intune and would love to see the whole process step by step.

      I have made some Autopilot configuration JSON files that I would like to deploy to my devices to get them to auto-join at the OOBE screen and make so I do not have to use flash drives.

      Reply
    5. Bob Wilkerson says:
      April 26, 2019 at 4:11 pm

      I think I am getting close as the device gets to the OOBE Screen and when I put in the configuration flash drive it joins up to Intune/AzureAD fine but under managed by it says “MDM/ConfigMgr Agent” and when I try to sign in it sits on Account Setup Identifying forever.

      Reply
    6. Yusuf Pietersen says:
      November 20, 2019 at 1:13 pm

      Hi,
      While in OOBE, I do not get the Shift F10 funtionality to work. Have you come across this?

      Reply
      1. fabio says:
        December 10, 2022 at 8:45 pm

        same problem here, did anybody find a solution to re-enable the shift+F10 in oobe after sysprep?
        thanks

        Reply
    7. JR says:
      November 21, 2019 at 7:51 pm

      Thanks for the info, works great! I do have a strange side effect when using this with AutoPilot.

      For some reason Intune will not deploy Win32 Apps to computers I have setup via AutoPilot after re-imaging this way. Intune reports them as “Waiting for Install Status”, and they never install.

      If I setup the system with a clean install of Windows from a USB key, AutoPilot + Install of Win32 Apps works flawlessly.

      Strange issue, just thought I would throw it out there in hopes that someone has dealt with this before.

      Reply
      1. Jörgen Nilsson says:
        December 15, 2019 at 10:54 pm

        What Configuration Manager version are you using?
        Regards,
        Jörgen

        Reply
    8. Håkan says:
      January 6, 2020 at 7:54 pm

      Is there any reason that you can think of, that this wouldn’t work when using White Glove?

      Reply
      1. Jörgen Nilsson says:
        January 10, 2020 at 1:11 pm

        No, maybe only if there are some leftovers from the cmclient.
        Regards,
        Jörgen

        Reply
    9. Chris says:
      March 19, 2020 at 12:24 pm

      Hi
      Im seeing a strange error using this method which results in a failed AutoPilot Enrollment with the error code 0x800705b4.

      I get this on a Hyper-V User Driven Enrollment the same on a physical device. I understand this is meant to be something with the TPM and despite disabling Bitlocker in the SCCM TS before deploying the new OS for AutoPilot it fails every time.

      Do you have any idea why this could be happening.

      Thanks

      Reply
    10. Pingback: SCCM Customize Windows Out Of Box Experience OOBE Using ConfigMgr How To Manage Devices
    11. daniel kusnir says:
      September 13, 2020 at 12:26 pm

      hi.

      Problem with this approach is that sometimes 3rd party may prevent from successful sysprep. For example, sometimes you can get an error :

      Sing-in process Initialization Failure
      interactive sign-in process initializaiton has failed
      Please check the even log for details

      This is caused by SMSTSPostAction running prior the logonUI, thus breaking the whole process.
      Depending how the image is built, most usual issue we found is with Office package included.

      Approach that worked for me was to add Autologon to Unattend.xml with logon count : 1 and add RunOnceRegistry to run your OOBE script after Administrator logs in for the 1st time.

      Reply
      1. Jörgen Nilsson says:
        June 9, 2021 at 3:41 pm

        Hi, Correct, I used a custom unattend.xml file with SKipMachineOOBE in which solves the issue.
        Regards,
        Jörgen

        Reply
    12. Christian says:
      January 14, 2021 at 6:47 pm

      The install + reset to OOBE works fine. But uninstalling CM agent doesnt work in my environment. CCMSetup.exe is removed and the Agent becomes bricked, only service is removed, but the software is still installed(Agent GUI). Any Ideas?

      Reply
      1. Jörgen Nilsson says:
        June 9, 2021 at 3:40 pm

        Hi, sorry for the late reply, it should be solved with the update I did now.
        Regards,
        Jörgen

        Reply
    13. Kevin McG says:
      July 27, 2021 at 10:33 am

      Good moring, I have just used this method to get our custom image to reboot and enter the OOBE, The above method would not work for me however by spliting the steps up and after OD install copy the PS to temp, then at the end of the TS run the PS script it works great.
      The issue i have is that once the device is in intune it works perfectly, however upon reboot the device will not boot, it just sits at black screen with revolving progress dots but will never procede.
      If i remove the Steps above the device works fine.
      I have enabled bootlogging but as i cant get in i can access it just now, i am about to try winpe to access the logs and will report back.

      Has anyone else had this issue or can think of what could be going on?

      Thanks.

      Reply
    14. Kevin McG says:
      July 27, 2021 at 1:58 pm

      Turns out the bootlogging gave up that the DXGKRNL.SYS driver is not loading.
      I cant understand what is being done during the running of the script, that the device will work great until its first reboot then fail to load a Graphics Driver.
      Any input would be welcome.

      Thanks

      Reply
    15. AlexD says:
      October 29, 2021 at 5:57 pm

      Hi, was doing this Task sequence for an offline PC (has internet but off from SCCM) using an ISO via USB. The OOBE appears to work but it doesn’t remove the sccm client. Reason why is because I need to join the PC to Azure AD. Thanks in advance for your inputs.

      Reply
      1. Jörgen Nilsson says:
        November 23, 2021 at 9:36 am

        Hi,
        Check and make sure that the SMSTSPOstaction ran succesfully
        Regards,
        Jörgen

        Reply
    16. Corstian says:
      November 20, 2021 at 1:15 pm

      Did you get this working? I have the exact same issue (black screen spinning wheel after reboot)

      Reply
      1. Jörgen Nilsson says:
        November 23, 2021 at 9:34 am

        Hi,
        Just tested it again works great. Must use a Custom Unattend.xml file that does NOT skip Machineboobe.. Otherwise it will fail.

        Regards,
        Jörgen

        Reply
    17. Corstian says:
      November 25, 2021 at 2:02 pm

      I’m confused, in the screenshot it says skipmachineoobe TRUE. I’m running 21H1 and the script removes de SCCM client and does a sysprep fine. after a users logs in, completes the enrollement process and reboots the device it hangs on a black screen with the spinning wheel just like @Kevin McG.

      Reply
    18. RogerH says:
      February 18, 2022 at 10:10 pm

      Some observations:
      1) you definitely need TWO unattend.xml files — one to skip the OOBE and one to run the OOBE – some baseline samples would be very helpful.

      The VERY light unattend_skipoobe.xml I built has left my screen just running the spinning wheel.

      and have been deprecated in Windows 10 and 11, so not sure if that’s causing issues with this, or if it’s the Office installation you mention being potentially problematic… will test both

      2) Watching my failures, I’m seeing the unattend.xml get cached into c:\windows\panther\unattend. Calling sysprep /oobe seems to be pulling this instead of the new unattend copied over in the prepareoobe step — /unattend:c:\windows\temp\unattend.xml

      Reply
    19. RogerH says:
      February 18, 2022 at 10:11 pm

      doh.. my xml pieces got edited out — skipmachineoobe and skipuseroobe

      Reply

    Leave a Reply Cancel reply

    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.

    My name is Jörgen Nilsson and I work as a Senior Consultant at Onevinn in Malmö, Sweden. This is my blog where I will share tips and stuff for my own and everyone elses use on Enterprise Mobility and Windows related topics.
    All code is provided "AS-IS" with no warranties.

    Tweets by ccmexec

    Recent Posts

    • Windows Servicing, Personal Teams and Success.cmd
    • Windows MDM Security Baseline – Settings Catalog
    • Configuring MS Edge Security Baseline v107 using Settings Catalog
    • Configuring Desktop App Installer using CSP and script?!
    • Customizing Taskbar and Start in Windows 11 22h2 with PowerShell

    ©2023 CCMEXEC.COM – Enterprise Mobility | WordPress Theme by Superb Themes
    This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish.Accept Reject Read More
    Privacy & Cookies Policy

    Privacy Overview

    This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
    Necessary
    Always Enabled
    Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
    Non-necessary
    Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.
    SAVE & ACCEPT