Last active
September 17, 2019 22:03
-
-
Save kellyebler/8e45697c1dbe10813f72ac0d430b1121 to your computer and use it in GitHub Desktop.
Finds out if we're enrolled in SimpleMDM and removes any profiles that are not installed by SimpleMDM if so.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
## find out if we're enrolled in SimpleMDM | |
mdmstatus=`/usr/bin/profiles status -type enrollment | grep MDM | /usr/bin/awk '{ print $3 }'` | |
if [ mdmstatus='Yes' ] | |
then | |
# Get a list of all profiles on computer that aren't 'unwiredmdm' and remove all of them | |
echo "MDM status is Yes. Removing profiles that aren't enforced by SimpleMDM" | |
for identifier in $(/usr/bin/profiles -L | grep -v unwiredmdm | /usr/bin/awk "/attribute/" | /usr/bin/awk '{print $4}') | |
do /usr/bin/profiles -R -p $identifier | |
done | |
exit 0 | |
else | |
echo "User not enrolled in MDM. Not touching profiles." | |
exit 0 | |
fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment