Extension Attribute: Computer Names Matching AD Objects

Matt
Valued Contributor

Hey all basically made a script for people with OCD like me who like the Sharing Names to match the AD Object Name. The first script I will post is just for reporting. Ill post another script that will fix any computers with mismatches. Essentially, make this script an Extension Attribute, Smart Group, and choose "Yes" for computers in compliance and "No" for computers that have mismatched names. Enjoy and feedback if you have a better way of making this work!!!!

#!/bin/sh

adObject=`dsconfigad -show | awk '/Computer Account/{print $NF}' | tr '[a-z]' '[A-Z]' | sed s/.$//`
sharingName=`scutil --get ComputerName`

if [ $adObject = $sharingName ] ; then
  echo "<result>Yes</result>"
else 
  echo "<result>No</result>"

fi
0 REPLIES 0