Guide to Changing Hostnames on Windows Autopilot Devices

More articles on Microsoft Intune | Windows Autopilot
Managing device naming conventions is a critical aspect of IT administration, especially when deploying devices at scale through Windows Autopilot. Whether you’re looking to implement a standardized naming scheme or need to rename devices after deployment, this comprehensive guide covers all the methods available to IT administrators.
Why Device Naming Matters
A well-structured device naming convention helps with device identification, inventory management, and troubleshooting. Instead of having randomly generated names like “DESKTOP-ABC123”, meaningful hostnames such as “HR-LAPTOP-001” or “SALES-WS-456” provide immediate context about the device’s purpose and location.
Method 1:
Apply Device Name Template in Autopilot Profile
The most straightforward approach is to configure device naming during the initial Autopilot deployment using the built-in device name template feature.
Setting Up the Template
- Navigate to the Intune admin center
- Go to Devices > Windows > Windows Autopilot Deployment Profiles
- Create a new profile or edit an existing Autopilot deployment profile
- Under General Settings, locate the “Apply device name template” option
- Enter your desired template string
Template Examples
You can create dynamic naming conventions using these macros:
- %SERIAL% – Uses the device’s serial number
- %RAND:x% – Adds a random string of x digits
Example templates:
MyCompany-%SERIAL%
creates names like “MyCompany-ABC123456”LAPTOP-%RAND:4%
creates names like “LAPTOP-7382”HR-WS-%SERIAL%
creates names like “HR-WS-DEF789012”
The template is automatically applied during the Autopilot enrollment process, ensuring consistent naming from the moment devices are deployed.
Method 2:
PowerShell Script During Enrollment
For more complex naming logic or custom requirements, you can use PowerShell scripts that execute during the Out-of-Box Experience (OOBE) or enrollment process.
Key Considerations for PowerShell Renaming
- Scripts must run with administrative privileges
- Use the
Rename-Computer
cmdlet for the actual renaming operation - Consider timing – the script should execute at the appropriate phase of enrollment
- Test thoroughly to ensure compatibility with your Autopilot configuration
Script Capabilities
PowerShell scripts offer flexibility to:
- Implement complex naming algorithms
- Query additional device information beyond serial numbers
- Integrate with external databases or APIs for naming schemes
- Apply conditional logic based on device characteristics
Method 3:
Remote Renaming with Intune
Sometimes you need to rename devices after they’ve been deployed and enrolled. Intune provides a convenient remote management option for this scenario.
Steps for Remote Renaming
- Open the Intune admin center
- Navigate to Devices > All devices
- Select the target device from the list
- Choose Rename device from the device actions menu
- Enter the new hostname
- Decide whether to restart the device immediately after renaming
This method is particularly useful for:
- Correcting naming mistakes after deployment
- Reorganizing devices due to role changes
- Updating naming conventions for existing devices
Method 4:
Hybrid Azure AD Joined Devices
Hybrid environments present unique challenges since devices need to maintain their identity in both on-premises Active Directory and Azure AD.
Special Requirements
For Hybrid Azure AD joined devices, you must:
- Delegate appropriate permissions for the computer object to rename itself in Active Directory
- Ensure the device has connectivity to domain controllers (often requiring VPN connectivity)
- Use specialized scripts that handle both local and domain naming requirements
Implementation Approach
The process typically involves PowerShell scripts that:
- Check for domain connectivity
- Verify appropriate permissions
- Rename the computer object in Active Directory
- Update the local computer name
- Handle the restart process properly
Important Considerations and Best Practices
Testing is Essential
Always test naming changes in a non-production environment before deploying to production devices. Device renaming can have unexpected impacts on:
- Application configurations that reference the hostname
- Network services that cache device names
- Security policies tied to specific computer names
- Certificate bindings and authentication services
Potential Issues to Watch For
Application Dependencies: Some applications store the hostname in configuration files or databases and may malfunction after a rename.
Autopilot Re-enrollment: If renaming causes issues with the Autopilot process, you might need to reset and re-enroll the device completely.
Timing Conflicts: Renaming too early or too late in the deployment process can cause enrollment failures or incomplete configurations.
Naming Convention Guidelines
When designing your naming scheme, consider:
- Consistency: Use a standardized format across all devices
- Clarity: Make names descriptive enough to identify the device’s role
- Length: Keep names within Windows’ character limits
- Scalability: Ensure your scheme can accommodate future growth
- Maintenance: Choose conventions that are easy to manage long-term
Choosing the Right Method
The best approach depends on your specific requirements:
- Use device name templates for straightforward, consistent naming during initial deployment
- Implement PowerShell scripts when you need complex logic or custom naming algorithms
- Leverage remote renaming for post-deployment corrections or reorganization
- Plan carefully for hybrid environments due to their additional complexity
Some final notes:
Effective device naming in Windows Autopilot environments requires careful planning and the right approach for your organization’s needs. Whether you implement naming during initial deployment or manage it post-enrollment, the key is thorough testing and a clear understanding of your environment’s requirements.
Remember that device naming is not just about organization—it’s a foundational element that affects device management, security policies, and user experience. Take the time to design a naming convention that will serve your organization well as it scales and evolves. By following these methods and best practices, you can maintain a well-organized device inventory that supports efficient IT operations and simplified device management across your Windows Autopilot deployment.
Resources:
Microsoft Official Documentation:
- Microsoft Learn – Autopilot Profiles: https://learn.microsoft.com/en-us/autopilot/profiles
- Microsoft Learn – Intune Device Rename: https://learn.microsoft.com/en-us/intune/intune-service/remote-actions/device-rename
- Microsoft Learn – Windows Autopilot Reset: https://learn.microsoft.com/en-us/autopilot/windows-autopilot-reset
Microsoft Community Forums:
- Setting BIOS Serial Number as Computer Name: https://learn.microsoft.com/en-us/answers/questions/689384/how-to-set-system-bios-serial-number-as-computer-n
- Rename Computer After/During Autopilot: https://learn.microsoft.com/en-us/answers/questions/1257535/want-to-rename-computer-after-or-during-autopilot
- Device Name Template in Azure AD: https://learn.microsoft.com/en-us/answers/questions/1518922/how-to-fix-device-name-template-in-azure-ad-joined
- Hybrid Join Renaming: https://learn.microsoft.com/en-us/answers/questions/648220/hybrid-join-renaming-manually
Technical Blogs and Articles:
- OOFHours Blog – Setting Computer Name with APv2: https://oofhours.com/2024/06/11/setting-the-computer-name-with-apv2/
- OOFHours Blog – Renaming Autopilot Deployed Devices: https://oofhours.com/2023/10/26/renaming-autopilot-deployed-devices/
- Niklas Tinner’s Medium Article – Bulk Autopilot Device Renaming: https://niklastinner.medium.com/bulk-autopilot-device-renaming-656ba517d94b
- LinkedIn Article – How to Rename Hostname Using Autopilot Intune: https://www.linkedin.com/pulse/how-rename-hostname-using-autopilot-intune-atish-b-gvotf
Community Discussions:
- Reddit r/Intune – Set ComputerName During Intune Autopilot: https://www.reddit.com/r/Intune/comments/175ort5/set_computername_during_intune_autopilot/
- Spiceworks Community – PowerShell Computer Name Replacement: https://community.spiceworks.com/t/power-shell-how-to-replace-a-computer-name-with-company-users-first-name/948677
Additional Resources:
- TechRepublic – Using Autopilot to Upgrade Existing Devices: https://www.techrepublic.com/article/using-autopilot-to-upgrade-existing-devices-to-windows-10/
- Microsoft Answers – Domain Name Change Effect on Intune Autopilot: https://answers.microsoft.com/en-us/msoffice/forum/all/domain-name-change-effect-on-intune-autopilot/4f7ff4d1-ed3f-45ec-8b7d-ce217c65149b