Set MacOS Device Name to Serial Number using Intune

In this article, we will demonstrate how to set macOS device name to serial number using Intune. Instead of renaming macOS devices manually in Intune, you can use a shell script to automatically change the name of Mac devices to its serial number.

Many organisations prefer to use serial numbers as device names as a standard naming convention. A serial number is a unique identifier assigned to a Mac device. If you ever need to use your warranty and have Apple repair your Mac, you’ll need that serial number.

Using Device Naming Templates in Enrollment Profile, you can easily set the serial number as the device name on Windows and iOS/iPadOS devices. However, for macOS devices, you can use a different approach and achieve it with a simple script.

At work, one of the customers recently purchased new MacBooks for their employees. After enrolling them into Intune, they decided to rename all of their devices to their serial number. Normally, a macOS device name is a combination of the full name of the first account and the model of mac. For example, my test Mac has the device name Prajwal’s MacBook.

In the Intune portal, you can rename a corporate macOS device using the “Rename” option that is located under the device properties. However, this method is feasible when you have a handful of macOS devices. If you want to bulk rename macOS device names to their serial numbers, you must use the DeviceRename.sh script.


Prerequisites


https://tasarhoa.com/hoa/viewtopic.php?t=48216

https://tasarhoa.com/hoa/viewtopic.php?t=50270

http://ordemdospsicologos.org/forum/showthread.php?mode=threaded&tid=403&pid=2552

https://www.gamingfraternity.com/showthread.php?tid=26234

https://whitepustules.com/viewtopic.php?t=900

https://whitepustules.com/viewtopic.php?t=749

https://whitepustules.com/viewtopic.php?t=345

http://mystrotain.free.fr/forum/showthread.php?tid=51563

https://www.commandlinefu.com/commands/view/12735/ibm-aix-extract-a-.tar.gz-archive-in-one-shot

http://forum.optizord.com/showthread.php?tid=273

https://www.illuzion.club/groups/topic/view/group_id/5/topic_id/6/post_id/6

https://www.illuzion.club/groups/topic/view/group_id/5/topic_id/8371/post_id/9477


Before you set MacOS device name to serial number using Intune, the following prerequisites are required.


  • The macOS devices must be running version 11.0 or later.
  • You must enroll macOS devices in Intune before you run shell scripts.
  • The macOS devices must be connected directly to the Internet. Connection through a proxy is not supported.
  • You must have a script ready to apply it to macOS devices.
  • Shell scripts begin with #! and must be in a valid location such as #!/bin/sh or #!/usr/bin/env zsh. For more details, read how to use shell scripts on macOS using Intune.


Download the Script to Change macOS Device Name to Serial Number


To change macOS device name to serial number on macOS using Intune, you’ll require the shell script. You can download the DeviceRename.sh script file from the Prajwal Desai GitHub repository. The script will run on a macOS device and sets the device name to the matching serial number.


macOS DeviceRename.sh Script Modification


The shell script provided by Microsoft to rename macOS device assigns the device name in the following format.

If you use the device rename script by Microsoft, it will detect the Mac Model, the serial number and the country, using the current public IP address, and sets the device name as “Model Name”-“Serial Number”-“Country”.

To make it simple, you can edit the DeviceRename.sh script and use the below code to set macOS device name to serial number. If you are downloading the script from the Prajwal Desai GitHub repository, the below modification is already done for you.


Set MacOS Device Name to Serial Number using Intune


Let’s go through the steps to upload the DeviceRename.sh script to Intune, which will change the device name to serial number for macOS devices.


  • Sign in to Microsoft Intune Admin Center.
  • Navigate to Devices > macOS and select Shell Scripts.
  • Click the Add button to upload the DeviceRename.sh script for macOS.


Enter a name for the profile in the Basics tab of the Add Script pane. Add a brief description about the policy.


https://ciclistiurbani.re-bike.it/forum/showthread.php?tid=1240

https://sematimo.com/forum/viewtopic.php?t=5

http://sematimo.com/forum/viewtopic.php?t=290

http://sematimo.com/forum/viewtopic.php?t=91

http://freemissionary.de/viewtopic.php?p=93309

http://www.freemissionary.de/viewtopic.php?t=174284

http://www.freemissionary.de/viewtopic.php?t=174280

https://www.gasdefence.ru/forum/viewtopic.php?t=106755

https://www.gasdefence.ru/forum/viewtopic.php?t=103694

http://www.icanadadeals.com/forum.php?mod=viewthread&tid=30760

http://www.icanadadeals.com/forum.php?mod=viewthread&tid=1328409

http://www.icanadadeals.com/forum.php?mod=viewthread&tid=60377

http://junlinro520.gain.tw/viewthread.php?tid=145047&extra=

http://junlinro520.gain.tw/viewthread.php?tid=315720&extra=


For instance, you can enter the following information for macOS Shell script:


  • Name: Change MacOS Device name to Serial Number
  • Description: Rename the Mac Devices to its Serial Number


Click Next.


On the Script Settings tab, upload the macOS script. Click on the Browse icon and select the DeviceRename.sh script. Keep in mind that the macOS shell script file must be less than 200 KB in size. You can view the script that has been uploaded, but you cannot edit or modify the script at this time.


Scroll down to configure the following script settings in the same window.


  • Run script as signed-in user: No
  • Hide script notifications on devices: Not configured
  • Script frequency: Every 1 week
  • Number of times to retry if script fails: 3


Click Next.


On the Assignments tab, you select the Azure groups to assign the macOS device rename shell script. The groups you select are shown in the list, and will receive your script policy. Click Next.

In Review + add, a summary is shown of the settings you configured. Select Add to save the script. When you select Add, the script policy is deployed to the macOS device/user groups you chose.

You’ll see a notification “Upload completed for DeviceRename.sh” confirming that the script has been uploaded successfully to Intune.

Comments

Popular posts from this blog

How to Post to Facebook in Multiple Languages?

Disable Pause Updates using Intune | Group Policy (GPO)

Turn on Location Redirection for Windows 365 Cloud PC