11-30-2022 05:37 PM - edited 11-30-2022 05:38 PM
I've seen this request pop up a few times and want to provide a general workflow for those who wish to rename system hostnames from the Display Name field in JumpCloud.
For those interested in more, I highly suggest the Advanced PowerShell Course on JumpCloud University. I've recorded how we can update systems display names based on device attributes. That series is a good introduction to advanced automations within the JumpCloud Module or PowerShell general.
In this example I'll just provide the steps to:
First let's get a CSV of all my systems. To do this let's run a simple script:
Connect-JCOnline "yourApiKey"
$systems = Get-JCSystem
$systems | ConvertTo-CSV | Out-File ./JumpCloudSystems.csv
This script will create a list of JumpCloud systems in your current working directory called "JumpCloudSystems.csv". Open this file with your editor of choice.
Next it's time to manually edit this file and update the column for "DisplayName" to be whatever you wish. Later we'll use our prebuilt scripts to update the device hostnames from the "DisplayName" of the desired system. In the screenshot below I've just written a short formula to concatenate the "SerialNumber" Column and "OsFamily" fields into the "DisplayName" Column.
Save the CSV. Next we'll update all the DisplayNames on JumpCloud.
$csv = Import-CSV -Path ./JumpCloudSystems.csv
foreach ($line in $csv){
Set-JCSystem -SystemId $line._id -DisplayName $line.displayName
}
This script will update each system's display name within JumpCloud.
Now that the display names have been set if you need to update systems actual hostnames follow the instructions for each mac/ windows/ ubuntu script. (These can be imported by clicking the Commands Tab, then adding a new command from Template, search for "rename"). In my organization. I've grouped all my systems by operating system using this script (which if run again will add new systems to their respective OS group). I've assigned my mac/ windows/ ubuntu scripts to each of these device groups and set the scripts to run once.
By default commands TTL settings are three days, I kicked off my commands manually so they will stick around the commands queue for three days before expiring. I can check the commands results tab to keep track of which systems were renamed and their status.
Depending on the OS, hostnames may not be set to the full length of the DisplayName stored in JumpCloud. Refer to your vendor and operating systems for specific limitations.
New to the site? Take a look at these additional resources:
Ready to join us? You can register here.