Extension Attribute to see Config Profile

cgordy
Contributor

Saw this previous thread:
https://jamfnation.jamfsoftware.com/discussion.html?id=5959
edit, sorry - lemme paste the code I am using:

#!/bin/sh

profiles=profiles -C -v | grep attribute | awk '/name/{$1=$2=$3=""; print $0}'
echo "<result> $profiles </result>"

exit 0

It works for me, but by design it shows all Config Profiles installed on my machine.

How can I re-phrase it to only show me the only one I am looking for with a Smart Group?
Staff WiFi would be specific.

Thanks!

1 ACCEPTED SOLUTION

mm2270
Legendary Contributor III

You should just be able to use syntax like:

Installed Config Profiles | Like | "Ringo"

which would gather all machines with that profile installed, regardless of any other profiles that are also installed. This is assuming mostly unique naming convention for all the profiles since it would be doing a string match.
Why would you also need to do a Not Like in the Smart Group? That shouldn't be necessary for the purpose of your Smart Group.

If you really only care about a single profile being present or not present, just use a grep in your above script to look specifically for the one profile you want, and then report back on the results. For example, if I wanted to build the EA to only look for the "MDM Enrollment" profile, I might do something like this:

#!/bin/sh

profiles=`profiles -C -v | grep attribute | awk '/name/{$1=$2=$3=""; print $0}' | grep "MDM Enrollment"`
if [[ ! -z "$profiles" ]]; then
    echo "<result>$profiles</result>"
else
    echo "<result>Not Installed</result>"
fi

exit 0

This would enter the specific profile name into the EA if it finds it, like "MDM Enrollment" for example. or, if not present, it would report "Not Installed". You could also build a Smart Group using that information.

View solution in original post

9 REPLIES 9

alexjdale
Valued Contributor III

I put a full list of configuration profiles into an extension attribute so I can use "like" or "not like" criteria to create smart groups around them.

cgordy
Contributor

I'm probably looking at this too closely, but using the code above I see all config profiles pushed to my machines…which is only five. My Smart Group is built using the "like".
Well, if I paint a picture…

Five Configs are pushed out and on the machines. They are called:
George
Ringo
John
Paul
Staff

If I build the smart group to "like" staff, but "not like" George, Ringo, John, Paul - then my smart group has nothing in it because I just told it to ignore a client if those items are not liked….

I'd think there'd be a nice way to reword that extension attribute code so that all I find is the single Config Profile called Staff, then build my smart group using "like". It's working despite all the clutter - my inventory display page went from a nice single line per-client to a bunch of huge paragraphs and spaces because it is trying to squish all of the other names of Config Profiles into a fairly small area on the screen, so it displays word-wrapped-kinda.

mm2270
Legendary Contributor III

You should just be able to use syntax like:

Installed Config Profiles | Like | "Ringo"

which would gather all machines with that profile installed, regardless of any other profiles that are also installed. This is assuming mostly unique naming convention for all the profiles since it would be doing a string match.
Why would you also need to do a Not Like in the Smart Group? That shouldn't be necessary for the purpose of your Smart Group.

If you really only care about a single profile being present or not present, just use a grep in your above script to look specifically for the one profile you want, and then report back on the results. For example, if I wanted to build the EA to only look for the "MDM Enrollment" profile, I might do something like this:

#!/bin/sh

profiles=`profiles -C -v | grep attribute | awk '/name/{$1=$2=$3=""; print $0}' | grep "MDM Enrollment"`
if [[ ! -z "$profiles" ]]; then
    echo "<result>$profiles</result>"
else
    echo "<result>Not Installed</result>"
fi

exit 0

This would enter the specific profile name into the EA if it finds it, like "MDM Enrollment" for example. or, if not present, it would report "Not Installed". You could also build a Smart Group using that information.

mscottblake
Valued Contributor
If I build the smart group to "like" staff, but "not like" George, Ringo, John, Paul

This means it will match any computers that has "staff" and does not have "George" or "Ringo" or "John" or "Paul". If any of those 4 are also installed, that computer will not be matched.

I believe what you are looking for is simply "like staff" with no "not like" portions. This makes a single Extension Attribute usable by multiple smart groups which will make Recon run faster.

cgordy
Contributor

@mm2270 - that is exactly what I was looking for. My Inventory Display page is no longer a stretched out mess because it is only seeing the specific profile I want.

Thanks!

mapurcel
Contributor III

Has anyone been able to modify this EA to work for User Profiles? Thanks!

Sonic84
Contributor III

I just needed the UUIDs for all installed profiles:

#!/bin/sh

profiles="$(profiles -P | grep attribute | awk '{print $4}')"
echo "<result> $profiles </result>"

exit 0

iweiss
New Contributor III

Thanks. I just added some sed to remove the white space at the beginning of each profile name.

#!/bin/sh

profiles=`profiles -C -v | awk -F: '/attribute: name/{print $NF}' | sed -e 's/^[ 	]*//'`

if [[ ! -z "$profiles" ]]; then

    echo "<result>$profiles</result>"

else

    echo "<result>Not Installed</result>"

fi

exit 0

Xopher
New Contributor III

FYI, running the above variants worked fine locally but as an EA I wasn't getting any results. I asked my Jamf TAM about this and he gave me the following that seems to be working:

#!/bin/bash

profiles=`profiles -P -v | awk -F: '/attribute: name:/{print $NF}' | sed 's/ //'`

    echo "<result>$profiles</result>"

exit 0