Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save talkingmoose/9efdfca3148bebc40fec1f8e7339d692 to your computer and use it in GitHub Desktop.
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.
#!/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