Who: Intune Administrators with corporate-owned machines that are not enrolled in Autopilot
What: Remotely retrieve hardware hash needed to enroll devices in Autopilot
When: After Autopilot is set up and tested in your environment, can be used to enroll machines that are already Intune-managed to Autopilot
Where: Intune Admin Portal and local machine
Why: It is, all told, fairly easy to get a single machine’s Hardware ID (HWID) if it is already Intune enrolled, but it’s a manual process. The HWID is in a CAB file, in a ZIP file, that is part of the Device Diagnostics that is requestable on Corporate-owned, Intune-managed devices. This script automates at least a part of that process.
How: There is still a manual, time consuming component to this, and that is downloading the diagnostic data from the target system(s). If you have a small number of devices, you can go to each Device page and collect diagnostics individually, or you can use a bulk device action to request diagnostics from up to 25 machines at a time.
Once diagnostics are available in the Intune portal (up to 24 hours), we need to save them to a single folder on the system we are planning on running the script from.
This script, quite simply, unzips each of the diagnostics archives in the folder, extracts the HWID CSV file from the CAB file contained within, then merges the CSV files together so you can easily bulk-import them into Autopilot.