Bulk Rename Corporate Hostnames on Windows & macOS via JumpCloud
Overview
When a new device is shipped to a user (Zero-Touch), it often arrives with a generic hostname like DESKTOP-8U29S or MacBook-Pro. To maintain asset inventory standards, IT admins need to rename these devices to a corporate standard (e.g., CORP-[SERIAL_NUMBER]) without disturbing the user.
This guide provides the scripts to automatically rename a device based on its Serial Number and reboot it.
Method 1: Windows (PowerShell Script)
This script fetches the device's BIOS Serial Number, appends a prefix, and renames the computer.
Log in to the JumpCloud Admin Portal.
Navigate to Device Management > Commands.
Click (+) and select Windows.
Name: Setup - Rename Windows PC to Serial.
Command: Paste the following PowerShell script:
# 1. Define your Prefix
$Prefix = "NXT-"
# 2. Get the Serial Number (BIOS)
$Serial = Get-WmiObject win32_bios | Select-Object -ExpandProperty SerialNumber
# 3. Construct New Name (Trim spaces to avoid errors)
$NewName = "$Prefix$Serial".Trim()
# 4. Rename the Computer
Write-Host "Renaming computer to: $NewName"
Rename-Computer -NewName $NewName -Force
# 5. Reboot to apply changes (Optional but recommended)
# Restart-Computer -ForceLaunch Type: You can run this manually on new devices or set it to run "After Agent Install" (if that feature is enabled in your plan) or via a specific "Onboarding" device group.
Note: The user will be forced to restart if you uncomment line 15. Ideally, communicate this to the user or allow them to restart at their convenience.
Method 2: macOS (Bash Script)
macOS has three different hostnames (ComputerName, HostName, LocalHostName). This script updates all three to ensure consistency.
Create a new Mac command in JumpCloud.
Name: Setup - Rename Mac to Serial.
Command: Paste the following Bash script:
#!/bin/bash
# 1. Define Prefix
PREFIX="NXT-"
# 2. Get Serial Number
SERIAL=$(system_profiler SPHardwareDataType | awk '/Serial/ {print $4}')
# 3. Construct New Name
NEW_NAME="${PREFIX}${SERIAL}"
echo "Renaming device to: $NEW_NAME"
# 4. Set Hostnames
scutil --set ComputerName "$NEW_NAME"
scutil --set HostName "$NEW_NAME"
scutil --set LocalHostName "$NEW_NAME"
# 5. Clear DNS Cache (Optional)
dscacheutil -flushcache
exit 0Settings: Run as root.
Effect: The change is usually immediate, though a reboot ensures the new name appears correctly in JumpCloud and network scans.
Important: Syncing the Name in JumpCloud Console
After the device renames itself locally, the name in your JumpCloud Admin Console might still show the old name (e.g., DESKTOP-ABC) until the next detailed system poll.
To force the console to update:
Wait for the device to check in (approx. 10-15 mins).
Or, run a second command:
Get-JCSystem -ForceRefresh(if the JumpCloud PowerShell module is installed).
FAQ
1) How do you rename a Windows PC hostname in JumpCloud using BIOS serial?
Use a JumpCloud Windows command with a PowerShell script that fetches the BIOS serial, adds a prefix, renames the computer, and reboots if enabled. This ensures standardized corporate hostnames.
2) How do you rename all macOS hostnames in JumpCloud using system serial?
Deploy a JumpCloud macOS Bash command that fetches the device serial via system_profiler and updates ComputerName, HostName, and LocalHostName using scutil. DNS cache can be flushed and reboot applied for consistency.
3) How does JumpCloud console update the hostname after serial-based rename?
JumpCloud reflects the new hostname after the device checks in or when a PowerShell refresh command is run to force a detailed system poll and update the console record.
4) Will JumpCloud serial-based hostname rename break Outlook, Slack, or email sync?
No. Hostname scripts modify only local system names. App sessions, email sync, and background services continue normally once the device authenticates and reconnects.
