Skip to content
Menu

Autopilot Hash Not Registered - Upload This PC's Hardware Hash

Run on the PC itself: it reads the hardware hash and serial number, skips a PC the tenant already holds, uploads the rest and waits for the import result.

Autopilot hash not registered - upload this PC's hardware hash is free for members.

Enter your email to create your free account and get the file.

We'll email you the script and the weekly MSP Outpost email. Unsubscribe anytime. Privacy policy.

Already a member? Sign in.

Be the first to review Autopilot hash not registered - upload this PC's hardware hash. Tell other MSPs how it worked for you.

Write a Review

LanguagePowerShell
Runs onWindows 10 1703+ or 11 (the PC being registered); runs as SYSTEM or a user
NeedsPowerShell 5.1; admin rights; Graph: DeviceManagementServiceConfig.ReadWrite.All; Intune and Entra ID P1
Changes thingsChanges what it runs on

What It Does

This script changes things in the tenant. It runs on the PC being registered, as SYSTEM or an administrator, not from a management server. It reads the hardware hash from the PC's device management WMI bridge and the serial number from the BIOS. It stops with an error when the PC reports no usable hash, as a virtual machine without TPM or SMBIOS data may not, or no usable serial number.

Then it checks whether the tenant already holds a device with that serial number. A registered Autopilot device, or an import that is complete or still running, ends OK with nothing uploaded. Otherwise it uploads the hash through Microsoft Graph, with GroupTag when you set one, and polls the import until Microsoft reports complete or an error, for up to WaitMinutes (1 to 60, default 10). The service can take several minutes.

An import that Microsoft rejects ends in an error with its reason; a common cause is a device already registered in another tenant. If the time runs out, the hash was uploaded and the error says to check Autopilot devices in the Intune admin center. A completed import can take a few more minutes to show as a device.

It never assigns an Autopilot profile, never deletes or edits an existing Autopilot device, and never writes the hash to disk or to the output. If you use a certificate, install it with its private key on each PC that runs the script, in LocalMachine\My or the running account's CurrentUser\My store. A client secret also works, but then it sits on every PC, so prefer the certificate. Microsoft's own page recommends registering by hardware hash only for testing and limited scenarios.

Before You Run It

  • Create an app registration with DeviceManagementServiceConfig.ReadWrite.All and grant admin consent. The tenant needs an Intune license and Microsoft Entra ID P1.
  • If you use a certificate, install it with its private key on the PC in LocalMachine\My or the running account's CurrentUser\My store.
  • Run it on the PC to be registered, as SYSTEM or an administrator, on Windows 10 version 1703 or later.
  • Set GroupTag if your Autopilot groups use one.
  • Run it with DryRun=true first to read the hash and check the tenant.

Type and Risk

  • Type: Action. It makes its change, checks the change worked and says what changed. It exits 0, or 2 when it could not do the job.
  • Risk: Low. Set DryRun=true, or run it with -WhatIf, to list every change without making any.
  • What it changes: Adds this PC's hardware hash to the tenant's Windows Autopilot devices (and a group tag when set).
  • Restart: It never restarts the machine.
  • Typical run: Under 12 minutes (most of it waiting for Microsoft's import).
  • Example answer: "Uploaded the hardware hash of PF3ABCDE to Autopilot with group tag Sales; import complete"
  • Tested before listing with Windows PowerShell 5.1, run as SYSTEM, against its own test cases and a Microsoft 365 Business Premium test tenant.

Inputs

Pass an input as an argument (-Name value), as an environment variable with the same name, which is how most RMMs pass script variables, or change its default in the param() block at the top of the script. An argument wins over an environment variable, which wins over the default.

  • TenantId: The tenant ID (a GUID) or a domain such as contoso.onmicrosoft.com.
  • ClientId: The app registration's Application (client) ID, a GUID.
  • CertificateThumbprint: Thumbprint of the app's certificate, which must be installed with its private key on this PC. Leave empty only if you use the ClientSecret environment variable.
  • GroupTag: Optional Autopilot group tag to put on the device (for example Kiosk). Default empty (no group tag).
  • WaitMinutes: How long to wait for Microsoft to finish the import. Whole number, 1 to 60. Default 10.

Every script also takes DryRun, OutputFormat (Text, Answer, Json or Csv), ExportPath and ResultField, which writes the answer to an RMM custom field.

License

Provided "as is" under the MIT License, without warranty of any kind. Test before production use. MSP Outpost and User First Digital Inc. accept no liability for any damage or loss.

The Script

invoke-autopilot-hash-upload.ps1 · 1083 lines · 60.2 KB

Free for Members

Create a free account or sign in to read, copy and download this script.

Welcome Back

Sign in to your MSP Outpost account.