Use this script to quickly register a device with Autopilot, such as a new VM for testing:
Write-Host 'Setting execution policy to Unrestricted...' -ForegroundColor Green
Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Force | Out-Null
Write-Host 'Installing NuGet package provider...' -ForegroundColor Green
Install-PackageProvider -Name NuGet -Force | Out-Null
Write-Host 'Installing Get-WindowsAutoPilotInfo script...' -ForegroundColor Green
Install-Script -Name Get-WindowsAutoPilotInfo -Force | Out-Null
Write-Host 'Installing WindowsAutopilotIntune module...' -ForegroundColor Green
Install-Module -Name WindowsAutopilotIntune -Force | Out-Null
Write-Host 'Executing "Get-WindowsAutoPilotInfo -Online -Assign"...' -ForegroundColor Green
Get-WindowsAutoPilotInfo -Online -Assign
I have this script is stored within this GitHub Pages site at https://ajf8729.com/ap.ps1, with the Bitly link http://bit.ly/getwapi pointed at it, so for complete ease of use, you can execute the script at the OOBE screen in PowerShell via:
iex (irm bit.ly/getwapi)
After running the above one-liner, come back in a minute or two and all of the necessary modules/scripts will be installed, without any prompts, and you should be at an authentication prompt to complete Autopilot registration!