Created
October 12, 2017 13:51
-
-
Save talkingmoose/9efdfca3148bebc40fec1f8e7339d692 to your computer and use it in GitHub Desktop.
Set the profileName variable on line 4 to the name or partial name of the profile(s) to remove. All profiles containing the profileName variable will be removed.
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/sh | |
# MDM profile name to remove | |
profileName="ABC Wi-Fi" | |
# list existing profiles and their UUIDs - must be run with elevated privileges | |
UUIDList=$( /usr/bin/profiles -Pv | grep "name: $profileName" -A 5 | grep profileUUID | awk -F "profileUUID: " '{ print $2 }' ) | |
# remove each profile by UUID | |
while IFS= read -r aUUID | |
do | |
echo "Removing profile UUID $aUUID" | |
/usr/bin/profiles -R -p "$aUUID" -u "$aUUID" | |
done <<< "$UUIDList" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment