How to upload Autopilot hashes from SCCM into Intune using PowerShell


2 min read

I was in need to gather Autopilot hashes to be able to migrate a subset of our SCCM clients into Intune to leverage the Autopilot feature.

Get Autopilot hashes from SCCM

As you may know, SCCM automatically gathers Autopilot hash from every Windows client during the Hardware inventory cycle. Such hash is then stored in the SCCM database so I've created a little PowerShell function Get-CMAutopilotHash (part of my SCCMStuff module) to get such hashes.

There is a bug in the new Windows Update that causes an error "Get-CimInstance : A general error occurred that is not covered by a more specific error code." when gathering the Autopilot hash. A temporary solution could be uninstalling such update wusa.exe /uninstall /KB:5013942 /norestart.

Upload Autopilot hashes into Intune

In general, you can upload Autopilot hashes manually or by Graph API. I've chosen the latter and created a function Upload-IntuneAutopilotHash (part of my IntuneStuff module).

Upload-IntuneAutopilotHash function supports setting of Autopilot device hostname, owner and groupTag. Can be run against local computer (gathers its hash) or accepts object with specific properties (SerialNumber, HardwareHash, Hostname, ownerUPN). Detailed information can be found in function help (Get-Help Upload-IntuneAutopilotHash -Full)


And the result can look like this ๐Ÿ‘‡

# install necessary modules
Install-Module IntuneStuff
Install-Module SCCMStuff

# get Autopilot hashes for selected devices
$data = Get-CMAutopilotHash -computername pc-01, pc-02, pc-03
# (optional) set OwnerUPN so the Autopilot devices have associated same owners as are in SCCM
$data = $data | select *, @{n='OwnerUPN';e={$_.Owner + ""}}

# connect to your AAD tenant

$data | Foreach-Object {
  Upload-IntuneAutopilotHash -psObject $_ -Verbose

Did you find this article valuable?

Support Ondrej Sebela by becoming a sponsor. Any amount is appreciated!