Display AD Computer Name in Self Service?

jefff
Contributor II

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.

1 ACCEPTED SOLUTION

mm2270
Legendary Contributor II

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

View solution in original post

2 REPLIES 2

mm2270
Legendary Contributor II

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

jefff
Contributor II

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