Posted on 04-24-2017 10:14 AM
I'm trying to do something like the below. Has anyone had experience removing user level config profiles that were locally installed? I can't get it to work.
#!/bin/sh
#find current user logged in
currentuser=`stat -f "%Su" /dev/console`
profile1=`su "$currentuser" -c "/usr/bin/profiles -Lv | grep LC-802`
profile2=`echo $profile1 | awk '{print $4}'`
echo $profilename
if [[ $profile2 == "LC-802" ]]; then
su "$currentuser" -c "/usr/bin/profiles -R -p 0F317018-2A6E-4828-8C1B-DD77B71E949B"
else
echo profile not found
fi
Posted on 04-24-2017 11:00 AM
I believe to un-install user level config profiles, you will need to have the profile somewhere on the machine locally, and pass it it in as a command line argument. The profiles man page shows the following example for -R:
profiles -R -F /profiles/testfile2.configprofile Removes the profile file '/profiles/testfile2.mobileconfig' into the current user.
Edit:
It would probably also be better to forgo the su instance and instead pass the user account into the commands. Possibly something like:
#!/bin/bash
currentuser=$(stat -f "%Su" /dev/console)
profile1=$(usr/bin/profiles -L -v -U "$currentuser" | grep LC-802 | awk '{print $4}')
echo $profilename
if [[ "$profile1" = "LC-802" ]]; then
/usr/bin/profiles -R -p 0F317018-2A6E-4828-8C1B-DD77B71E949B -U "$currentuser"
else
echo "profile not found"
fi