Skip to main content
Question

script to rename devices

  • October 25, 2023
  • 6 replies
  • 98 views

danlaw777
Forum|alt.badge.img+17

Has anyone made a script or profile to rename devices in jamf pro? right now, there is onl;y 1 option (within pre-stage enrollment) and i'd like to have a 2nd. my goal it to name the phones using a prefix of P followed by the serial, and a prefix of a T for the ipads. 

 

anyone doing something like this?

6 replies

Forum|alt.badge.img+15
  • Valued Contributor
  • October 25, 2023

I don't manage iOS devices in Jamf, just Macs but here's what I'm using for renaming Macs by adding a prefix of "M-" before the serial number. Maybe it will help lead you in the right direction? 

#!/bin/sh prefix="M-" serial=`system_profiler SPHardwareDataType | awk '/Serial Number/ { print $4 }'` sudo /usr/sbin/scutil --set ComputerName "${prefix}${serial}" sudo /usr/sbin/scutil --set HostName "${prefix}${serial}" sudo /usr/sbin/scutil --set LocalHostName "${prefix}${serial}" sleep 5 exit 0

 


Forum|alt.badge.img+1
  • New Contributor
  • October 26, 2023

I don't manage iOS devices in Jamf, just Macs but here's what I'm using for renaming Macs by adding a prefix of "M-" before the serial number. Maybe it will help lead you in the right direction? 

#!/bin/sh prefix="M-" serial=`system_profiler SPHardwareDataType | awk '/Serial Number/ { print $4 }'` sudo /usr/sbin/scutil --set ComputerName "${prefix}${serial}" sudo /usr/sbin/scutil --set HostName "${prefix}${serial}" sudo /usr/sbin/scutil --set LocalHostName "${prefix}${serial}" sleep 5 exit 0

 


Hello, how could this script be modified to use M- but only the last 7 characters of the serial number?


Forum|alt.badge.img+20
  • Valued Contributor
  • October 26, 2023

Hello, how could this script be modified to use M- but only the last 7 characters of the serial number?


Grep the serial number.


mickgrant
Forum|alt.badge.img+12
  • Contributor
  • October 27, 2023

Hello, how could this script be modified to use M- but only the last 7 characters of the serial number?


This script should do what you asking for

#!/bin/sh SerNum=$(ioreg -rd1 -c IOPlatformExpertDevice | awk -F'"' '/IOPlatformSerialNumber/{print $4}') lastSeven="${SerNum: -7}" jamf setComputerName --name $lastSeven -prefix "M-"

Forum|alt.badge.img+1
  • New Contributor
  • August 7, 2024

This script should do what you asking for

#!/bin/sh SerNum=$(ioreg -rd1 -c IOPlatformExpertDevice | awk -F'"' '/IOPlatformSerialNumber/{print $4}') lastSeven="${SerNum: -7}" jamf setComputerName --name $lastSeven -prefix "M-"

@mickgrant 

https://www.bing.com/search?q=api+script+to+rename+device+building+name+jamf&qs=n&form=QBRE&sp=-1&ghc=1&lq=0&pq=api+script+to+rename+device+building+name+jam&sc=6-45&sk=&cvid=AF3BD4C36E68419B81E4BF4836F34B24&ghsh=0&ghacc=0&ghpl=

Please let me know what u suggest on this


Forum|alt.badge.img+1
  • New Contributor
  • August 7, 2024