Smart group if computername is serialnumber as variables

beeboo
Contributor

Aside from making an EA then making smart groups based on that value, is it possible with the native GUI to do the following:

  1. create new smart group
  2. select "computer name" is/is not/like/etc
  3. select "serial" or add in $Serial_Number or something like that

that way I can compare the values that JSS already has - serial in hardware, computer name in general.

Otherwise the crappy way would be run the policy to rename computer name once a week or something but have no group reporting :(
Thanks!

2 REPLIES 2

sdagley
Esteemed Contributor II

@beeboo There's no way to create a Smart Group like you ask without involving an EA. Depending on your naming policy, and whether or not you use AD binding, the easiest thing to do would probably be have a script that runs daily/weekly that checks to see if the current computer name meets your org's standards and rename if not.

Gonzalo
New Contributor III

You can use this EA (thanks @mm2270

#!/bin/sh

computer_name=$(scutil --get ComputerName)
serial_number=$(ioreg -rd1 -c IOPlatformExpertDevice | awk -F'"' '/IOPlatformSerialNumber/{print $4}')

if [ "$computer_name" == "$serial_number" ]; then
      result="Yes"
else
      result="No"
fi

echo "<result>$result</result>"