Updating the Hostname and the Local Hostname Using a Policy

Jamf Pro Documentation 11.16.0

Solution
Application
Content Type
Technical Documentation
Utilities & Services
version
11.16.0
ft:locale
en-US
vrm_version
11.16.0

To update the hostname, computer name, and the local hostname, you need to create a script that includes the new computer name. Then, you can run the script using a policy. The command used in this script can update computers dynamically when DNS services are configured on the network.

When updating the hostname and the local hostname, use the following guidelines:

  • Use a hyphen instead of spaces.

  • The only special character you can use is a hyphen.

  • Case is not sensitive.

  • Non-alphanumeric characters are ignored.

You can also add the following options to the command used in the script:

-target <target volume>

Sets the name when the computer is booted to the specified target volume

-name <name>

The new name for the computer

-useMACAddress

Changes the name to the primary MAC address

-useSerialNumber

Changes the name to the serial number

-suffix <suffix>

Adds this suffix to the MAC address or serial number. For example:

sudo jamf setComputerName -useMACAddress -suffix '-example'
-prefix <prefix>

Adds this prefix to the MAC address or serial number. For example:

sudo jamf setComputerName -useMACAddress -prefix '-example'
-fromFile <file path>

The path to a CSV file containing the computer's MAC address or serial number, followed by the new name. For example:

sudo jamf setComputerName -fromFile '/file/path'
  1. In Jamf Pro, click Settings in the sidebar.
  2. In the Computer management section, click Scripts .
  3. Click New.
  4. Use the General pane to configure basic settings for the script, including the display name and category.
  5. Click the Script tab and enter the following in the script editor, modifying it for your environment: sudo jamf setComputerName
  6. Click Save.

You can now run the script by creating a policy with the script added to the Scripts payload.