Posted on 03-03-2021 08:51 AM
Current have a script that extracts a full computer configuration from a user's computer but would like have a "Copy" button which allows for the content of the dialog box to be copied to clipboard for pasting in email. Has anyone had any success in this?
03-23-2022 01:50 PM - edited 03-23-2022 01:51 PM
Hello, I have been playing around and come up with this. Feel free to tweak for your environment.
#!/bin/bash
JHELPER="/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper"
USERNAME=$(ls -l /dev/console | awk '{print $3}')
currentUser=$(who | awk '/console/{print $1}')
echo $currentUser
ID=$( dscl "/Active Directory/AD/All Domains/" -read /Users/$currentUser | grep employeeID | awk '{ print $2 }' )
echo $employeeID
ASSETTAG=$(scutil --get LocalHostName)
COMPUTERNAME=$(scutil --get ComputerName)
IPE=$(Ipconfig getifaddr en1)
IPW=$(ipconfig getifaddr en0)
THEMESSAGE="Logged on User: $USERNAME
Employee Number: $ID
Computer Name: $ASSETTAG
Ethernet IP Address: $IPW
WIFI IP Address: $IPE"
MESSAGE=$("$JHELPER" -windowType utility -title "Computer Info :: $COMPUTERNAME" -description "$THEMESSAGE" -button1 "Close" -button2 "Copy Details" -defaultButton 1 -icon "insert a icon" -iconSize 128)
if [ "$MESSAGE" == "0" ]; then exit 0
elif [ "$MESSAGE" == "2" ]; then
echo Username: $USERNAME$'\n'Employee Number: $ID$'\n'Computer Name: $ASSETTAG$'\n'WIFI IP Address: $IPE$'\n'Ethernet IP Address: $IPW | pbcopy
exit 0
fi