HomeNewsletterCommunityMVP FeedToolsArchiveBlogToday's NewsAboutServicesQuick Links Subscribe free
← Back to Blog
Autopilot AutopilotIntuneDevice namingNetBIOSMicrosoft EntraHybrid joinMicrosoft GraphPowerShell

Autopilot device naming templates: the 15-character wall and the duplicate hostnames it silently creates

IA
Imran Awan
21 August 2026

The device name template in a Windows Autopilot deployment profile is one line of text. You type a prefix, you add %SERIAL%, you move on. It is the least interesting field in the whole profile, which is exactly why it is the one that quietly breaks your estate eighteen months later.

The failure is not loud. Nothing errors. Two laptops finish the out-of-box experience (OOBE) perfectly, both enrol, both go compliant. They just happen to have the same hostname. Domain Name System (DNS) starts flapping between two addresses for one record, Remote Help lands on the wrong machine, and your asset report has a row you cannot explain. This post covers the character arithmetic that causes it, what Microsoft actually documents about truncation, and how to design a template that cannot collide.

The short version

An Autopilot device name template must generate 15 characters or fewer, because that is the NetBIOS computer name ceiling. Microsoft documents exactly two variables, %SERIAL% and %RAND:x%, and documents that an over-long serial is truncated from the beginning of the sequence - so a long prefix keeps only the tail of the serial, and two devices from one vendor batch can land on identical names. Microsoft states plainly that these macros do not guarantee uniqueness and do not check whether a name already exists. Microsoft Entra hybrid joined devices cannot use the variables at all: the Domain Join profile takes a prefix only.

The problem: two laptops that answer to one hostname

The ticket usually arrives from the service desk rather than from monitoring. A technician starts a remote support session, connects, and finds a different user's desktop. Or a software deployment reports success on a machine that never received it. Or DNS answers for the same hostname with two different addresses, depending on which record won the last dynamic update.

When you go looking, the picture is confusing. The two systems that ought to flag the problem both think everything is fine.

intune.microsoft.comDevicesAll devices

Intune shows two rows with an identical Device name. Microsoft Entra ID shows two device objects with an identical displayName. Neither platform complains. That is not a bug, it is by design. The Entra device object is keyed on deviceId, a unique identifier set by the Device Registration Service at registration time. The Intune record is keyed on its own id. The display name is just an attribute, and two objects with the same attribute value are perfectly legal.

Context: the cloud tolerates duplicate device names. Name resolution does not. Entra ID and Intune both key devices on globally unique identifiers, so duplicates simply sit side by side in the portal. DNS, NetBIOS name registration, and any script that resolves a device by name have no such luxury. They have exactly one answer to give, and they will give you the wrong one roughly half the time.

So the damage shows up wherever the name is the primary key rather than an attribute:

None of this is caused by a broken Autopilot service. All of it traces back to one line of text in a deployment profile.

Why it happens: a 15-character budget and a serial cut from the front

Start with the ceiling. Microsoft's Active Directory naming reference is explicit about NetBIOS computer names. The minimum length is one character and the maximum name length is 15 characters, because the sixteenth character is reserved for identifying the functionality registered on the network device. The same article adds that Windows does not permit computer names longer than 15 characters, and that you cannot specify a DNS host name that differs from the NetBIOS host name. That is the wall. Everything else is arithmetic against it.

The Autopilot profile documentation restates the constraint in product terms. On the out-of-box experience page of the profile wizard, Apply device name template carries this rule: names must be 15 characters or less, they can have letters, numbers and hyphens, and they cannot be all numbers. The Microsoft Graph reference for the underlying deviceNameTemplate property says the same thing from the other direction. The total length of the text generated by the template can be no more than 15 characters.

The two variables Microsoft documents, and only two

There are exactly two. Anything else you have seen in a forum thread is not a documented Autopilot variable, and inventing one will simply produce a literal string in your hostname.

VariableWhat Microsoft documents it doesDocumented example
%SERIAL%Generates the serial number derived from the device. If the serial number causes the new name to exceed the 15-character limit, the serial number is truncated from the beginning of the sequence.Test-Device-%SERIAL% generates Test-Device-456
%RAND:x%Generates the specified number of random digits, where x is the count of digits to add.Test%RAND:6% generates Test123456

Two documented details matter more than the syntax. First, from the Accounts configuration service provider (CSP): using any of these macros will limit the new name to 15 characters. Second, from the DevDetail CSP node that supersedes it: the character restriction limit does not count the length of the macros themselves. The budget is spent by the output, not by the template text. So CONTOSO-%SERIAL% is a 16-character string that is a perfectly valid template, because only the literal CONTOSO- counts against the 15.

The arithmetic nobody does before clicking Create

Take 15, subtract every literal character in the template, and what remains is the number of serial characters that survive. That is the whole model.

TemplateLiteral charactersSerial characters that survive
CT-%SERIAL%312
CTS-%SERIAL%411
CTS-UK-%SERIAL%78
CONTOSO-%SERIAL%87
CTS-UK-LDN-%SERIAL%114
CTS-UK-LDN-FIN-%SERIAL%150

Now apply the documented truncation direction. The serial is cut from the beginning, so what survives is the tail. Consider two devices from the same vendor purchase order, with serials that differ only in their leading block.

PowerShell — the template arithmetic, worked by hand
Template : CONTOSO-%SERIAL% Literals : 8 characters ("CONTOSO-") Budget : 15 - 8 = 7 characters left for the serial # two illustrative serials from one vendor batch, differing only at the front Device A : MJ0ABCD1234567 -> keep last 7 -> 1234567 Device B : MJ0XYZE1234567 -> keep last 7 -> 1234567 # both devices now generate the SAME name, and nothing warns you Result A : CONTOSO-1234567 Result B : CONTOSO-1234567

That is the entire mechanism. A generous prefix looks tidy in a spreadsheet and destroys the distinguishing part of the serial number. Vendors that encode plant or line codes at the front and a sequential counter at the back survive truncation fine. Vendors that do the opposite, with the unique block first and a common batch suffix last, collide the moment your prefix grows.

Watch out: Microsoft states this outright rather than leaving it implied. The Accounts CSP documentation says that when you use these naming macros, a unique name is not guaranteed and the generated name can be duplicated. The DevDetail CSP documentation adds that the feature does not check whether a particular name is already present in the environment. There is no server-side collision check anywhere in this path. If your template can produce a duplicate, it eventually will, and the service will let it through.

The gotcha that eats your serial entirely

A common instinct on discovering truncation is to bolt a random suffix on the end, something like CTS-%SERIAL%-%RAND:3%, so that colliding serials get separated. Microsoft documents that this does not work the way you expect.

Gotcha: the DevDetail CSP documentation for the DNSComputerName node states that if both macros are in the string, the random macro takes priority over the serial macro and the serial is ignored. A template containing both variables does not blend them. The random digits win and the serial is dropped, so you get a name with no hardware relationship at all. That is the opposite of what you were trying to achieve. Pick one variable, not both.

What %RAND:x% actually buys you

%RAND:x% is genuinely collision-resistant, but only if you spend enough characters on it. Microsoft's guidance is directional rather than numeric. The Accounts CSP says to use the random macro with a large number to reduce the likelihood of a duplicated device name. The DevDetail CSP recommends either macro with a high character limit to reduce the chance of a name collision.

Microsoft does not publish a collision probability table, so here is the ordinary birthday arithmetic instead. For n devices drawn from N possible names, the expected number of colliding pairs is roughly n squared divided by 2N. The figures below are that formula applied to a 5,000-device estate. They are my arithmetic, not a documented Microsoft value.

Random digitsDistinct names availableExpected colliding pairs at 5,000 devices
%RAND:4%10,000about 1,250, so guaranteed pain
%RAND:5%100,000about 125
%RAND:6%1,000,000about 12
%RAND:8%100,000,000about 0.13
%RAND:11%100,000,000,000about 0.0001

The lesson is uncomfortable but simple. Six random digits, the value most templates use, is not enough for a mid-sized estate. Eleven digits is, and with a three-character prefix plus a hyphen you can afford exactly eleven.

Hybrid join takes a different path entirely

Everything above applies to Microsoft Entra joined devices. The profile field itself is gated, because Apply device name template requires the Microsoft Entra join type. For Microsoft Entra hybrid joined devices the naming happens in a separate Domain Join configuration profile, and Microsoft is blunt about its capability. The naming capability for Windows Autopilot for Microsoft Entra hybrid join does not support variables such as %SERIAL%, and it only supports prefixes for the computer name. The Autopilot profile page says the same thing more briefly: only a prefix can be provided for hybrid devices in a Domain Join profile.

So on the hybrid path you supply a Computer name prefix and the remainder of the 15 characters is generated for you. Two consequences follow. Your prefix is a direct tax on randomness, because a longer prefix means fewer generated characters and a higher collision rate, with no serial number available to compensate. And renaming afterwards is not an escape route. Microsoft documents that renaming Microsoft Entra hybrid joined devices from Intune is not supported, and that you must use domain-based methods outside Intune instead.

Tip: there is no Group Policy setting that renames a computer, so there is no on-premises fallback to reach for here. The supported surfaces are the Autopilot deployment profile, the Domain Join configuration profile, the Intune rename device action, and the Accounts or DevDetail CSP applied as a custom profile. Treat the template as the only real control point, and get it right before the first device ships.

How to verify: read the template, do the arithmetic, hunt the collisions

Verification has three layers. What the profile says, what the device ended up with, and whether the estate already contains duplicates.

1. Read the Entra-join template in the portal

intune.microsoft.comDevices › EnrollmentDeployment Profiles
  1. Sign in to the Microsoft Intune admin center.
  2. Select Devices in the left hand pane, then select Windows under By platform.
  3. Under Device onboarding, select Enrollment.
  4. Under Windows Autopilot, select Deployment Profiles.
  5. Open the profile, then select Settings.
  6. Find Apply device name template. Read the template string and count its literal characters.
  7. Subtract that count from 15. That number is how many serial characters your devices actually keep.

2. Read the hybrid prefix in the Domain Join profile

intune.microsoft.comDevices › ConfigurationTemplates › Domain Join
  1. Select Devices, then Manage devices | Configuration, then Policies.
  2. Open the profile built from the Domain Join template for platform Windows 10 and later.
  3. Read the Computer name prefix. Every character here is a character not available for uniqueness.
  4. Note the Domain name and the optional Organizational unit in distinguished name format, so you know which Active Directory container the duplicates would land in.

3. Confirm what the device actually got

PowerShell — on the device (run elevated)
(Get-CimInstance Win32_ComputerSystem).Name # the NetBIOS name in force right now - healthy output is 15 characters or fewer (Get-CimInstance Win32_BIOS).SerialNumber # the value %SERIAL% draws from - compare its tail against the hostname Get-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName' -Name ComputerName Get-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Control\ComputerName\ActiveComputerName' -Name ComputerName # if these two differ, a rename is staged and takes effect on the next restart dsregcmd /status # AzureAdJoined and DomainJoined tell you which naming path this device took

The registry is where a pending rename hides. Microsoft documents the two locations in its Workstation service troubleshooting article. The non-volatile ComputerName subkey holds the name that will apply, and the volatile ActiveComputerName subkey holds the name currently in force. If they disagree, the device is mid-rename and a restart will change its identity.

All three values below sit under one parent key:

HKLM\SYSTEM\CurrentControlSet
Relative subkeyValue (REG_SZ)What it tells you
Control\ComputerName\ComputerNameComputerNameThe persisted NetBIOS name. This is the name that applies after the next restart.
Control\ComputerName\ActiveComputerNameComputerNameThe volatile, currently active name. Microsoft documents that a missing value here stops the Workstation service with error 2250.
Services\Tcpip\ParametersHostnameThe DNS host name of the computer returned by the hostname command. Defaults to the computer name.
Registry EditorHKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\ControlComputerName
Registry Editor — illustrative view of a device caught mid-rename
Control\ComputerName
   +-- ComputerName             ComputerName = CTS-01947382651
   +-- ActiveComputerName    ComputerName = CONTOSO-1234567
Services\Tcpip\Parameters
   +-- Hostname                  CONTOSO-1234567
Gotcha: Microsoft does not publish an event log identifier catalogue for device name template evaluation, and Autopilot does not raise a dedicated event when a template truncates or collides. Rather than invent identifiers, treat the absence as the finding. There is no event to alert on, which is precisely why a scheduled Graph audit is the only reliable detection. Collect the standard Mobile Device Management (MDM) diagnostics if you need to trace CSP application, but do not expect a naming-specific event to exist.

4. Audit the whole estate for duplicates

Because there is no service-side check and no event to watch, detection has to be a query. The companion script for this post reads Intune managed devices and Entra device objects, groups them on name, and reports three things. Exact duplicates, names sitting at or within one character of the 15-character ceiling, and names whose shape suggests a truncated serial. It performs GET requests only and uses read-only scopes.

PowerShell 7 — Get-DeviceNameCollisionReport.ps1 (illustrative output, names redacted)
Connect-MgGraph -Scopes DeviceManagementManagedDevices.Read.All,Device.Read.All === Intune managed devices : 4,812 Windows records read === Entra device objects : 4,977 Windows records read --- DUPLICATE NAMES (Intune) --- CONTOSO-1234567 2 records serials: MJ0ABC... / MJ0XYZ... CONTOSO-7654321 2 records serials: MJ1DEF... / MJ1GHI... --- AT OR NEAR THE 15-CHARACTER CEILING --- 15 characters : 3,914 devices # no headroom left at all 14 characters : 198 devices --- POSSIBLE TRUNCATED SERIAL PATTERN --- prefix 'CONTOSO-' plus 7 numeric characters : 3,914 devices # a fixed prefix landing on exactly 15 characters is the signature of truncation RESULT: 2 duplicate name group(s) found. Exit code 2.

The fix: a template that cannot collide

The design goal is a template where collision is arithmetically impossible or vanishingly unlikely. Not one that merely looks organised. Four rules get you there.

  1. Spend at most four characters on literals. A three-character prefix plus a hyphen leaves eleven characters. That is enough for most full serial numbers, and enough for %RAND:11%.
  2. Do not encode site, department or role in the hostname. Those attributes change without the hardware changing, and every character they consume is stolen from uniqueness. Put them in Entra device categories, group membership or extension attributes, where they can be edited without a rebuild.
  3. Pick one variable. Because the random macro takes priority and the serial is ignored when both appear, a mixed template silently becomes a random-only template.
  4. Measure your vendors' serials before choosing. Run the audit script against your existing estate and look at serial length, and at how many serials share a tail. If the last few characters are not unique across your fleet, use %RAND:11% rather than %SERIAL%.
TemplateGenerated lengthVerdict
CTS-%SERIAL%4 plus up to 11Good, if every vendor serial is unique in its last 11 characters.
CTS-%RAND:11%15 exactlyBest for collision resistance. No hardware relationship, so keep the serial number in Intune inventory instead.
CONTOSO-%SERIAL%8 plus up to 7Risky. Only 7 serial characters survive.
CTS-UK-LDN-%SERIAL%11 plus up to 4Do not ship this. Four characters cannot identify a device.
CTS-%SERIAL%-%RAND:3%4 plus 3Broken by design. The serial is ignored entirely.

Changing the template on an existing profile

  1. Go to Devices, then Windows, then Enrollment, then Deployment Profiles.
  2. Select the profile and choose Settings.
  3. Set Apply device name template to Yes and enter the new template.
  4. Review the generated length against the 15-character budget one more time, then save.
Watch out: Microsoft documents that changes to a deployment profile are applied to devices assigned to that profile, but the updated profile is not applied to a device already enrolled in Intune until after that device is reset and enrolled again. Editing the template fixes future deployments only. It does nothing for the duplicates already in your estate. Those need a rename, and on Microsoft Entra hybrid joined devices a rename from Intune is not supported at all.

Remediating names that already collided

For Microsoft Entra joined devices the Intune rename action is the supported path, and its rules are looser than the template's. The rename action permits a name of up to 63 characters, allows letters, numbers and hyphens, forbids spaces, forbids names that contain only numbers, and publishes an explicit disallowed-character list. Bulk rename additionally requires a variable in the name, and note that the syntax differs from the Autopilot template. It is {{serialnumber}} and {{rand:x}} with double braces, not percent signs.

intune.microsoft.comDevices › All devicesBulk Device Actions › Rename
  1. Select Devices, then All devices, then Bulk Device Actions.
  2. On the Basics page, set OS to Windows and set Device action to Rename.
  3. Enter a name that includes {{serialnumber}} or {{rand:x}}.
  4. Select the affected devices, then complete the configuration wizard. Choose whether to restart after rename.
Context: the rename action's 63-character allowance comes from DNS, not NetBIOS. The DevDetail CSP node behind it documents a maximum allowed length of 63 characters as per DNS standards. That does not mean you should use them. Windows still does not permit computer names that exceed 15 characters, so anything longer will not behave as a usable hostname. Treat 63 as the interface's tolerance and 15 as the real limit.

Proof it worked: unique names and a quiet DNS zone

The proof here is negative evidence, which makes it easy to skip. Do not skip it. Re-run the audit after the template change and after the renames, and confirm three things. Zero duplicate groups, headroom below 15 characters where you expect it, and no fixed-prefix cluster sitting on the ceiling by accident.

PowerShell 7 — re-run after remediation (illustrative output, names redacted)
=== Intune managed devices : 4,812 Windows records read === Entra device objects : 4,977 Windows records read --- DUPLICATE NAMES (Intune) --- none --- DUPLICATE NAMES (Entra) --- none --- AT OR NEAR THE 15-CHARACTER CEILING --- 15 characters : 4,112 devices # expected: CTS-%RAND:11% fills the budget by design --- POSSIBLE TRUNCATED SERIAL PATTERN --- none detected # no fixed prefix plus shared numeric tail RESULT: 0 duplicate name group(s) found. Exit code 0.

Then confirm the downstream symptoms have cleared. In DNS, each hostname should resolve to one address consistently across repeated lookups. In Entra ID, a search on the previously duplicated name should return a single object. On a rebuilt device, the persisted and active computer name registry values should match, meaning no rename is left staged. And if you are co-managed, the Configuration Manager console should stop generating fresh duplicate records for the affected names.

One last habit is worth adopting. Put the audit on a schedule rather than running it after an incident. Because there is no event log signal and no service-side uniqueness check, a monthly report is the only thing standing between a careless template edit and a hostname collision you discover through a mis-routed support session.

References

Community deep-dives that cover the same ground from a practitioner angle. Both were fetched and confirmed on topic before being listed here.

AuthorPostWhy it is worth reading
Peter van der WoudeThe different ways of (re)naming Windows 10 devicesCompares all four naming surfaces, custom OMA-URI, Domain Join profile, Autopilot profile and device properties, and is explicit that the hybrid remainder is random.
Maurice Daly, MSEndpointMgrHow to rename Windows 10 devices in Intune using PowerShellA practical Graph-driven bulk rename, including slicing a fixed number of characters out of a serial number. Useful when you need a deterministic remediation rather than a random one.

The companion read-only audit script for this post is Get-DeviceNameCollisionReport.ps1 in the Windows Autopilot scripts collection. It performs GET requests only, prompts before installing any module, and exits non-zero when it finds a collision so you can wire it into a scheduled job.

PowerShell — companion script

Download it from Imran76Awan/Windows-Autopilot-Scripts — no sign-in required. It is read-only: it reports and never changes a device or anything in Intune. Validate it in your own environment before relying on the output.

Get-DeviceNameCollisionReport.ps1 — Read-only audit for Windows device name collisions caused by Autopilot device
View all scripts on GitHub
Was this post helpful?
React below — no account needed
Share this post
LinkedIn X / Twitter Reddit Bluesky

More from EndpointWeekly

Autopilot
The Autopilot Conditional Access deadlock: requiring a compliant…
A brand-new Autopilot device cannot be compliant before it is enrolled, so a Conditional…
Autopilot
Enrollment Configuration Priority: Why Your Second ESP Profile…
Device configuration profiles merge. Device enrollment configurations do not. Exactly one…
Autopilot
Corporate or personal? How Autopilot devices get their ownership…
Intune stamps device ownership at enrolment time based purely on the enrolment route.…