Getting Hardware hash for Intune Devices

Tags azure intune

 

How To...

How to get Hardware hash for Intune devices

Steps To Implement

GET A NEW COMPUTER’S AUTO PILOT HASH WITHOUT GOING THROUGH THE OUT OF BOX EXPERIENCE (OOBE)

 

With Auto Pilot you need to import a machines Auto Pilot hash, or hardware ID, to register the device with the Windows Auto Pilot deployment service in Azure. Ideally, the process of getting the Auto Pilot hash would be performed by the OEM, or reseller from which the devices were purchased, but currently the list over participating resellers is small. The other option is to do it manually which requires you boot the device up, go through the out of box experience (OOBE), and then run a PowerShell script which will spit out the hash CSV for you to then import into Auto Pilot. This process can be time consuming if you have a batch of new machines, and once you get the hash for each device, you must reset it so during the next boot it will go through the OOBE and enroll via Auto Pilot.

In this post I will show you how you can grab the Auto Pilot hash from the machine manually, but without going through the entire OOBE process and device reset. This method will also allow you to hit multiple machines as it will append your csv file for each machine you run it on, allowing you to only have to do the import process once instead of after each run.

Preparation

There are 2 files we need to create / download and place on a removable USB drive. First we need to download the latest Get-WindowsAutoPilotInfo from the PowerShell gallery

On another machine open PowerShell with elevated privileges and run Install-Script -Name Get-WindowsAutoPilotInfo 

Next, navigate to C:\Program Files\WindowsPowerShell\Scripts and copy the Get-WindowsAutoPilotInfo.ps1 file to your USB drive

Next create a .CMD file with the script block below. You can simply open notepad, paste the text below, and save it as GetAutoPilot.CMD

@ECHO OFF

echo Enabling WinRM

PowerShell -NoProfile -ExecutionPolicy Unrestricted -Command Enable-PSRemoting -SkipNetworkProfileCheck -Force

echo Gathering AutoPilot Hash

PowerShell -NoProfile -ExecutionPolicy Unrestricted -Command %~dp0Get-WindowsAutoPilotInfo.ps1 -ComputerName $env:computername -OutputFile %~dp0compHash.csv -append

echo Done!

pause

Your USB drive contents should look like the following:

Getting the Hash Without Going Through OOBE

Now on your new computer, attach your USB drive to it. We don’t need to boot from the USB, we just need it to be available for us to use. When we first turn on the computer we should be greeted with the region information or something similar. This means we are in the out of box experience.

To bring up the Command Prompt, press Shift + F10 on the keyboard

Next, we need to figure out the drive letter for our USB drive. Enter DISKPART and then list volume. In my example, my USB drive did not get a drive letter so I will select my USB volume (volume 4) by running select volume 4, and then assign it drive letter R by running assign letter=R

NOTE: Most often your drive will automatically be assigned the letter D. If this is the case you can skip this part and proceed past the DiskPart portion

By running list volume again I can now see my USB drive has the letter ‘R’ assigned to it

Type exit to desk DiskPart

Now we can change over to that drive by simply typing the drive letter and then a colon. In my example I will run R: 

The last step we need to do is to run the CMD script. So, in your command prompt just type GetAutoPilot.cmd and then press ENTER. Once it is finished running I can simply turn off the machine until I finish importing the hash into Auto Pilot, the next time it boots it will still be at the OOBE process, but since I would have imported the hash and assigned an Auto Pilot profile, it will automatically go through the Auto Pilot process.

If we were to plug the USB back into our main machine we can now see there is a CSV on there called compHash, and it contains our AutoPilot hash for our machine. We can either upload this into our Auto Pilot in Azure, or run this on other machines as it will keep appending the csv file.

 

 

Print Article

Details

Article ID: 389
Created
Thu 6/9/22 9:46 AM
Modified
Mon 3/6/23 3:28 PM