Skip to main content

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?

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

 


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?


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


Grep the serial number.


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-"

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


@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


JAMF api for fetching building details not working... - Jamf Nation Community - 321977


Reply