Windows VM get stuck at OOBE Sysprep screen in Azure Cloud

Windows VM get stuck at OOBE Sysprep screen in Azure Cloud

February 21, 2018 0 By Amir Joseph Sayes

Credit goes to Richard Podd for finding the solution for this – Thanks Rich!

Summary

Windows VM get stuck at OOBE Sysprep screen in Azure. Boot diagnostics would just show the logon screen as if the OOBE sysprep was successful, RDP would connect but authentication won’t work.

Environment

  • Windows 10
  • Hyper-V for building the VHD on premise
  • Microsoft Azure

Scenario and Steps Taken

On On-Premise Hyper-V server

Convert the VM from VMDK to VHD – All OK
Prepare image for upload to Azure: Preperation Steps and Sysprep showed all OK with no errors in Sysprep logs.

On Microsoft Azure

Convert uploaded VHD to image in Azure – All OK
Deploy managed Disk VM from VHD Image in Azure – All OK
Create Managed Disk image from Managed Disk VM in Azure – All OK
Deploy Managed Disk VM from Manage Disk Image in Azure: This is where we had issues, Boot Diagnostics Data would just show the logon screen as if the OOBE Sysprep was successful, RDP would connect but authentication won’t work. This was tested with a domain joined image and without domain joining.
Reviewing the logs on the failed deployed VMs would show no errors, as would the Sysprep logs.

Troubleshooting

If we downloaded the image as a VHD to On-Premise Hyper-V server and booted the VM; OOBE would go through, then at the point where you are asked to create a new user to log in to the machine you would be met with the error ‘an error has occurred’, however clicking ‘Next’ again would go to the next step.

From this we assumed that the creation of the user account was failing for some reason.

The Solution

What worked for us was to clear our AppX packages from the local admin account as well as the logged on user.

  • If you are logged on as local admin to the image:
# Delete all local profiles
Get-WmiObject -Class Win32_UserProfile | foreach {try{$_.Delete()} catch{}}
# Clean up AppX Packages
Get-AppxPackage -AllUsers | Remove-AppxPackage -ea SilentlyContinue | Out-Null
Get-AppxProvisionedPackage -Online | Remove-AppxProvisionedPackage -Online | Out-Null
  • For remote execution, put the above script in a Powershell file, and execute it remotely using psexec.exe
$tmpPassword = “localadmin password”
& "c:\YourTempPath\psexec.exe" -h -accepteula -u "$($env:ComputerName)\LocalAdminAccount" -p "$($tmpPassword)" powershell.exe -File “C:\YourTempPath\yourscriptfile.ps1"