How to Rename Hostname Using Autopilot in Intune...?
?? Overview
When managing devices with Intune and Autopilot, it's common to enforce a naming convention that includes the device’s serial number or other identifiers.
?? Your Requirement
You want to configure a hostname that:
? Uses the device serial number in the name.
? Adds a prefix (e.g., "A") to the serial number.
? Applies to both new and existing devices.
? Solution Options
1?? Use Autopilot Deployment Profile (For New Devices)
2?? Use a PowerShell Script via Intune (For Existing Devices)
?? Method 1: Configure Hostname in Autopilot (For New Devices)
If the device is new or being re-enrolled, you can define a naming convention in Autopilot.
1?? Create an Autopilot Deployment Profile
2?? Apply Device Name Template
A{{SerialNumber}}
This ensures all devices follow this format: Example: A1234567890
Click Next, assign it to a device group, and Save.
? Devices will be named automatically when they enroll via Autopilot.
?? Method 2: Rename Existing Devices Using PowerShell in Intune
For devices already deployed, Autopilot’s device name template won’t apply. Instead, use a PowerShell script to rename them.
1?? Create the PowerShell Script
# Get the device serial number
$SerialNumber = (Get-WmiObject Win32_BIOS).SerialNumber
# Define new hostname with "A" prefix
$NewComputerName = "A$SerialNumber"
# Rename the computer
Rename-Computer -NewName $NewComputerName -Force
# Restart to apply changes
Restart-Computer -Force
Save it as Rename-Device.ps1.
2?? Deploy the Script via Intune
? Devices will rename on next policy sync & reboot.