Autopilot hybrid-join device naming PowerShell scripts

While Azure AD-only join deployment profiles require following the Microsoft-specified device naming template, naming devices with hybrid-join deployment profiles is much more flexible.

Endpoint Manager Autopilot lets you specify a PowerShell device naming script that will run during hybrid-join. If the PowerShell script returns the value of a valid computer name, that string will be used to name the device.

If the return value is not a valid computer name, or there was an error, or no PowerShell script was added, then the hybrid-joined device will use the supplied device name prefix followed by a dash, plus a five-digit random number.

Currently, no device-specific data is supplied to the script as parameters when it is run. The return string must be returned from the script with the 'return' operator. For example: return $generatedComputerName.

When you create or update a deployment profile, the PowerShell script is saved in the Endpoint Manager database and not in Azure with the deployment profile itself. Also, the script runs on the core server, not on the client device, and the device name is used when creating the Offline Domain Join (ODJ) Blob.

Due to the Windows calls that are made to create the ODJ Blob, the valid character rules for the computer name are the same as those of DNS names and not regular NETBIOS host names. We also recommend the generated names are kept to the Microsoft specified 15-character limit or less.

To use a computer name generation PowerShell script
  1. In the Autopilot window, click Deployment profiles.
  2. Click Create.
  3. On the Basics page, enter a profile Name and Description. Click Next.
  4. On the Out-of-box-experience page, select Hybrid Azure AD joined.
  5. Under Computer name generation PowerShell script, click Select file and browse for the script you want.

  6. Finish configuring the deployment profile and save it.