Posted on 10-14-2013 04:47 AM
Hi guys
im trying to get my AD deparment.
So when i do
dscl /Active Directory/RUFUS_DOMAIN/All Domains/ -read /Users/tkimpton
i want to be able to get my department
dsAttrTypeNative:department: Information Systems
Problem is im having problem outputting just Information Systems.
Can anyone help me?
Thanks
Solved! Go to Solution.
Posted on 10-14-2013 07:17 AM
I just tried this and received the proper info back:
tell application "Finder"
set Department to do shell script "dscl /Active\ Directory/INTEGERDALLAS/All\ Domains/ -read /Users/swood dsAttrTypeNative:department | grep -oi 'information systems'"
display dialog Department
end tell
The trick for me were the double back slashes and then the single quote in the grep statement.
Posted on 10-14-2013 05:59 AM
Hey fella,
Is that on 2 lines?
Have a look @ head & tail.
Something like that. Is this fot populating AD info innthe Jss?
Posted on 10-14-2013 06:01 AM
had a bit of a blank lol
this worked
dscl /Active Directory/RUFUS_DOMAIN/All Domains/ -read /Users/tkimpton department | tr -d '
' | awk '{$1 =""; print }' | sed '1s/^.//'
Posted on 10-14-2013 06:03 AM
Not the prettiest way to do it, but grep might work as well. A quick test of this worked for me:
dscl /Active Directory/INTEGERDALLAS/All Domains/ -read /Users/swood dsAttrTypeNative:department | grep -oi "information systems"
That returned "Information Systems" for my user, and when I tried a user that had a different department, it returned blank. For users that had no department it returned "No such key: dsAttrTypeNative:department".
Posted on 10-14-2013 06:03 AM
Hi Ben
yeah its on the second line. I know theres lots of ways of doing things and eventually thought of it.
Its there an easier way with head and tail?
would be easier to remember lol
Posted on 10-14-2013 06:25 AM
bit of a problem trying to get my original command in an Applescript :(
Anyone know how i can do this?
Posted on 10-14-2013 06:36 AM
Brilliant Steve. Im trying to get this in an applescript and having problems with it though. I have tried
set Department to do shell script "dscl /Active Directory/RUFUS_DOMAIN/All Domains/ -read /Users/tkimpton dsAttrTypeNative:department | grep -oi "Information Systems"
Posted on 10-14-2013 07:17 AM
I just tried this and received the proper info back:
tell application "Finder"
set Department to do shell script "dscl /Active\ Directory/INTEGERDALLAS/All\ Domains/ -read /Users/swood dsAttrTypeNative:department | grep -oi 'information systems'"
display dialog Department
end tell
The trick for me were the double back slashes and then the single quote in the grep statement.
Posted on 10-14-2013 07:28 AM
Thanks Steve much appreciated, you brought me back from the brinks of madness
This is what is used for the applescript in the end
set loggedInUser to do shell script "whoami"
set ISDepartment to do shell script "dscl /Active\ Directory/RUFUS_DOMAIN/All\ Domains/ -read /Users/" & loggedInUser & " dsAttrTypeNative:department | grep -oi 'Information Systems'"
Posted on 11-29-2020 05:42 AM
hi do we have any updated script to update AD user full name department email id and more to update to inventory via extension attribute or policy can help