Skip to main content

Does anyone have a script they'd be willing to share to display the computer's Active Directory name in Self Service? I've tried writing my own script and it's a challenge that exceeds my meager scripting abilities.



In case that's not clear, I'm looking for something along the lines of the scripts posted in this thread that displays the "Computer ID" in AD, instead of the IP address and ComputerName.

Something like this?



#!/bin/bash

ADCompName=$(dsconfigad -show | awk -F'= ' '/Computer Account/{print $NF}')

if [[ ! -z "$ADCompName" ]]; then
text="Your Active Directory computer name is:

$ADCompName"
else
text="Your Mac is not joined to Active Directory"
fi

/usr/bin/osascript << EOD
set diagText to (do shell script "echo "$text"")
tell application "System Events"
display dialog diagText buttons {"OK"}
end tell
EOD

Wow, thanks so much! That is just what I need.