Modern Management - Part Ten - Harvesting Autopilot Hardware IDs

There are numerous arctiles around showing how to use Config Manager or MDT to harvest and repurpose Autopilot hardware IDs for existing equipment. I have a client who wanted a scirpt based method to collect the hardware IDs of their existing estate.


Here's a simple solution I came up with using Get-WindowsAutoPilotInfo.ps1 (version 1.6) by Michael Niehaus and legacy methods.

So we start with a server we will use to host the script and collect the hardware IDs.

In my example I'm going to use a VM I have called DC01.DOMAIN.LOCAL

I've created a share called HWID and given everyone read and write access (both NTFS and Share permissions).

I've then create a batch file called HWID.cmd which contains the following:

# ScriptName = HWID.cmd
# Purpose = Collect Autopilot Hardware ID for existings clients and save to a file share
# Author = Neil Petersen
# Date = 20190903

# Version = 1.00

MD C:\HWID
Copy \\DC01.DOMAIN.LOCAL\HWID\Get-WindowsAutoPilotInfo.ps1 C:\HWID\
PowerShell -executionPolicy bypass -file "C:\HWID\Get-WindowsAutoPilotInfo.ps1" -OutputFile C:\HWID\%computername%.csv -Append

Copy C:\HWID\*.csv \\DC01.DOMAIN.LOCAL\HWID\


The next thing I have done is just to create a simple GPO (linked to the root of the domain in this example):



Once, applied to the client machine:



Simply reboot the client. On reboot you should have a directory called HWID on the root of the C drive of the client with the script and the hardware ID csv file there.


then check your file share and if all is well, you'll have your Autopilot Hardware IDs for your clients in a central location (I have two in this example, WIN10 and WAC01):




Please note....
1) Clients must be on the network and have the GPO applied (therefore probably best to leave it a few days/weeks/months before Importing the devices into Intune)
2) As you can see there's no error checking
3) Scripts/output files could be stored in a nicer place
4) The file names could be amended if required
5) There's probably 100 different ways to skin a cat, but it's simple and its working here (well this was tested on a couple of Windows 10 end clients).

You can then import your devices using the Intune Portal, Store for Business or via PowerShell:


Install-Module AzureAD
Install-Module WindowsAutoPilotIntune
Import-Module WindowsAutoPilotIntune
Connect-AutoPilotIntune

#Import-Device

Import-AutoPilotCSV -csvFile C:\temp\AutoPilotHWID.csv 




Comments

Post a comment