JAMF Recon command not updating certain info

boberito
Valued Contributor

I have a script that worked perfectly the last 2 school years so probably pre-Casper 9. Since we upgraded to Casper 9 mid school year last year.

This script figures out who the current logged in user is and then hits Active Directory to get their AD group which is their graduation class and their full name. We then have departments named the same in Casper. This worked beautifully in the past but seems to have broken some time in the last year. And maybe it's my script but that hasn't changed.

#!/bin/bash

getUser=`ls -l /dev/console | awk '{ print $3 }'`

getclass=`dscl '/Active Directory/ACADEMIC/All Domains' -read /Users/$getUser dsAttrTypeNative:distinguishedName | awk '{ FS=","; print $2 }' | awk '{ FS="="; print $2 }'`

getRealName=`dscl '/Active Directory/ACADEMIC/All Domains' -read /Users/$getUser RealName | grep -v ":"`

jamf recon -endUsername $getUser -department "$getclass" -realname "$getRealName" -email "$getUser@saes.org"

When I do the jamf recon command but manually put -department "Class of 22" instead of using the variable it will set it to the department in Casper named "Class of 22" correctly.

When I check to make sure the variable $getclass has the right value it does (echo $getclass returns Class of 22).

Anyway I wasn't sure if this is a bug? Something I'm doing wrong? Something anyone else has seen? Any help would be greatly appreciated.

1 ACCEPTED SOLUTION

mm2270
Legendary Contributor III

You may want to double check that the string the variable is receiving is exactly what its required to be for the JSS to recognize the pre-defined department. What I mean is, if its being returned with even so much as an extra space or odd character in it, it may not match up and thus not populate when it gets recon'ed with that info.
You can have it echo the variable out to a text file as part of troubleshooting, and then check the text file afterwards to see what its echoing. It could even be a carriage return or something.

View solution in original post

9 REPLIES 9

Look
Valued Contributor III

Some predefined extension attributes are tied to JSS information and will only populate if it matches something in the list.
ie: Unless there is a department defined as "Class of 22" in the JSS it will not populate.

edit: That's my understanding anyway.

boberito
Valued Contributor

No you are exactly right. And we have a department named "Class of 22" defined in Casper's list of available departments. It works in the script if I don't use the variable. That's why I'm so confused.

calumhunter
Valued Contributor

@Look is correct. The department your wanting to match must already exist in the JSS.

bentoms
Release Candidate Programs Tester

@boberito, have you got network segments overriding the departments?

boberito
Valued Contributor

@bentoms Nope, not that I know of. We don't really use network segments at all here.

chriscollins
Valued Contributor

When is this script being run? Is it possibly being run when a user isn't actually logged into the system?

boberito
Valued Contributor

First login. All the other information populates perfectly like username, real name, and email.

mm2270
Legendary Contributor III

You may want to double check that the string the variable is receiving is exactly what its required to be for the JSS to recognize the pre-defined department. What I mean is, if its being returned with even so much as an extra space or odd character in it, it may not match up and thus not populate when it gets recon'ed with that info.
You can have it echo the variable out to a text file as part of troubleshooting, and then check the text file afterwards to see what its echoing. It could even be a carriage return or something.

boberito
Valued Contributor

YES! You were right. I really really appreciate this. I guess I was lucky it was working before.