Archive for 7 April 2019

Harvesting Hardware Hash for Autopilot

Harvesting hardware hash for Microsoft Autopilot is simple for a single computer as can be seen at

SCCM if you are using it has a report that you can run the provides the Hash details for all your computers, but I have found about a 20% failure rate with the Hash provided and importing it into Autopilot with this method in testing. The Hash provided by the powershell script found in the article link above always works for me.

So how to run the Get-WindowsAutoPilotInfo script on computers including laptops that rarely come to the office and collect the data in a central place. Use SCCM to deploy a script to run Get-WindowsAutoPilotInfo on each computer and copy the output file to a central file share. Then gather that data to import it into Autopilot.

My SCCM deployment targets all Window 10 computers on which it runs batch file install.bat. This file copies Get-WindowsAutoPilotInfo and autopilot.bat to the targeted computers an runs autopilot.bat.

xcopy /s /e . c:\programdata\autopilot\
cd c:\programdata\autopilot

Autopilot.bat runs, generates a csv file and copies it to a fileshare.

powershell -executionPolicy bypass -file “Get-WindowsAutoPilotInfo.ps1” -OutputFile .\%computername%.csv -Append

xcopy *.csv \\fileshare\

Consolidating all the csv files into a single file is easily done with the powershell file found at

$getFirstLine = $true

get-childItem “c:\path\to\files\*.csv” | foreach {?
    $filePath = $_?

$lines = Get-Content $filePath  ?
    $linesToWrite = switch($getFirstLine) {?
           $true  {$lines}?
           $false {$lines | Select -Skip 1}?


$getFirstLine = $false?
    Add-Content “c:\path\to\files\final.csv” $linesToWrite?