Automate Windows Autopilot Device Naming with PowerShell – Introducing Update-AutopilotDeviceNames
If you’ve spent any time managing Windows Autopilot at scale, you’ve almost certainly wrestled with device naming. Autopilot does give you some native options here — but as soon as your organisation has its own asset numbering system, those options fall short fast.
That’s why I built Update-AutopilotDeviceNames, a PowerShell script now published to the PowerShell Gallery and available on GitHub.
The Problem — and Why Autopilot’s Native Naming Isn’t Always Enough
Windows Autopilot supports device naming through Autopilot Deployment Profiles. You can define a name template using a prefix combined with either a random alphanumeric string or the device’s serial number — for example, CORP-%SERIAL% or WKS-%RAND:5%. For many environments, that’s perfectly adequate.
But here’s where it breaks down: what if your organisation already has a CMDB with unique asset numbers assigned to every device? What if your hardware arrives with asset labels physically attached — stickers on the chassis that your service desk, finance team, and CMDB all refer to? In those cases, CORP-%SERIAL% is next to useless. You don’t want a name derived from the serial number — you want the device named after the asset number that’s already on record.
Maybe you’re a procurement team that receives a bulk order of 200 laptops. Before they even reach users, your CMDB has assigned asset IDs to each one, cross-referenced against serial numbers captured at the point of receipt. You have a spreadsheet — or can easily produce one — with two columns: serial number and desired device name. The serial number is the link between your asset register and the Autopilot record. What you need is a way to feed that mapping directly into Autopilot so the device gets the right name when it enrols.
That’s exactly the gap this tool fills.
What the Script Does
Update-AutopilotDeviceNames connects to Microsoft Graph and handles two core jobs:
1. Export Mode (-ExportCurrent)
Pulls all Windows Autopilot device identities from your tenant and writes them to a timestamped CSV. The export includes serial number, current display name, manufacturer, model, group tag, purchase order, and enrolment state. This gives you a clean baseline to work from — you can review what’s already named, spot gaps, and edit the file to feed back into the update process.
2. Update Mode (default)
Takes a CSV you provide, maps serial numbers to desired device names, and applies them via the Graph Beta endpoint using the updateDeviceProperties action. It’s smart about what it touches: by default it skips devices that already have a display name, so you’re not accidentally overwriting intentional names. Use -ForceUpdate if you need to overwrite existing values.
The script produces a full results report CSV with one of these statuses for every device processed:
| Status | Meaning |
|---|---|
Updated | Display name was successfully applied |
AlreadyNamed | Device already had a name; skipped (use -ForceUpdate to override) |
NoDeviceFound | Serial number wasn’t found in your Autopilot tenant |
DuplicateName | The desired name appears more than once in your CSV; skipped to avoid conflicts |
NoChange | Current name already matches the desired name; no action taken |
WhatIf | Would have updated, but -WhatIf was passed; no changes made |
Failed | An error occurred during the update attempt |
Key Features Worth Highlighting
-WhatIf Support
Before committing any changes, run the script with -WhatIf. It goes through the full logic — connects to Graph, loads your CSV, evaluates every device — but makes zero changes. It still generates a report CSV showing exactly what would happen. This is the first thing I’d recommend doing before any production run.
| |
Flexible CSV Input
The script accepts either a DeviceName or DisplayName column alongside SerialNumber, so it works whether you’re building a fresh naming list or editing an export you’ve already generated with -ExportCurrent. The -ExportCurrent workflow is probably the cleanest path: export what you have, edit the DisplayName column, then feed it straight back in.
Configurable Report Output
You can pass -ReportOutputPath with either a folder path (the script generates a timestamped filename for you) or a full file path if you want to control the exact output name. It defaults to C:\Temp if you don’t specify anything.
| |
Duplicate Name Detection
If your CSV accidentally contains the same desired device name against two different serial numbers, the script detects it, flags both entries in the report as DuplicateName, and skips them entirely. No silent conflicts.
Prerequisites
- Module:
Microsoft.Graph.Authenticationmust be installed - Permissions:
DeviceManagementServiceConfig.ReadWrite.Allvia Microsoft Graph - Graph endpoint: Uses the Beta endpoint for Autopilot device identity properties
- The script authenticates interactively using
Connect-MgGraph— it’ll prompt for credentials if you’re not already connected
How to Install
The script is published to the PowerShell Gallery, so installation is straightforward:
| |
Or if you’re using PSResourceGet:
| |
A Typical Workflow
Here’s how I’d approach this for an organisation receiving a bulk device order where the CMDB already has asset numbers assigned against serial numbers.
Step 1 — Prepare your CSV
Your starting point is a CSV with two columns: SerialNumber and DeviceName. This is the mapping between the serial number captured at receipt (or from your supplier’s delivery manifest) and the asset label or CMDB asset number you want the device named after. It might look something like this:
| |
If you already have an existing Autopilot estate and want to see what’s currently named before making changes, use -ExportCurrent first to generate a baseline:
| |
Open the CSV, review the current DisplayName values, and update any that need changing.
Step 2 — Preview the changes
| |
Check the WhatIf report. Confirm the Updated count looks right and there are no unexpected NoDeviceFound entries.
Step 3 — Apply
| |
Step 4 — Verify
| |
Run a fresh export and confirm the DisplayName values have propagated as expected. The script even reminds you to do this at the end of every update run.
Important Limitations to Be Aware Of
Because this is built on top of how Windows Autopilot actually works, there are constraints that are by design:
- Naming only applies at enrolment. If a device is already provisioned, updating the display name in Autopilot does not rename the device — it only takes effect the next time that device goes through the Autopilot provisioning process.
- Microsoft Entra joined devices only. Hybrid Azure AD Join scenarios are not supported for Autopilot device naming.
These aren’t limitations of the script itself — they reflect the underlying platform behaviour.
Wrapping Up
This script came out of a real need I kept running into across different environments — particularly where organisations already had asset numbering systems or CMDB records in place and needed device names to align with those, not with whatever Autopilot’s prefix+serial template would produce. The serial-to-name CSV approach means your existing asset data becomes the source of truth, and the export-edit-update loop makes it practical to maintain naming standards across large Autopilot estates without touching the portal. The -WhatIf support means you can validate confidently before making any changes.
The full source is on GitHub and the script is published to the PowerShell Gallery If you run into any issues or have suggestions, feel free to raise them on the repo.
Build it right.
Name it right.
Before it ever turns on.
