When migrating to the modern Autopilot world, if you are not purchasing net-new devices, you may find yourself having to rebuild current ones.
This means getting these devices into Autopilot devices. The most popular option (and rightly so) is to use the Get-WindowsAutopilotInfo script, whether that’s the official one or the community edition
Sometimes though, you might want a more simple solution, something a bit plug-and-go. This is something I recently came across so thought why not script it!
V2.0 update – Now supports language/locale selection for ISO
You can grab the script from GitHub here
Or from PowerShell Gallery:
Install-Script -Name create-windows-iso-with-apjson
The result is a new script to create a Windows ISO, running the script will do the following:
- List your Autopilot profiles in a grid-view to select the one to use
- Prompt for a language for the ISO
- Grab the JSON for you
- Popup the OS choice, this is grabbed directly from Microsoft to list only the currently supported versions
- Create a new folder in c:\temp to work from
- Grabs the ISO URL using the excellent Fido from Pete Batard
- Downloads the ISO
- Mounts the ISO
- Grabs the Windows Professional WIM from within in
- Mounts the WIM and injects the autopilot JSON
- Converts the new WIM to an ISO (using oscdimg)
- Cleans up everything but the ISO
As with all scripts, you can supply parameters to use an Azure App Reg for the Autopilot profile part so you could run this on an automated schedule.
When using this with an Autopilot dynamic group, the rule needs to be:
(device.devicePhysicalIDs -any (_ -startsWith "[ZTDid]")) -or (device.enrollmentProfileName -eq "OfflineAutopilotprofile-PROFILEIDHERE")
Replace PROFILEIDHERE with the ID listed in the initial popup when selecting the profile to deploy (it’s also in the address bar within the Intune portal)
Hopefully you find this useful!