Remove all OSX profiles through command line

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 03-21-2016 06:59 AM
Hi,
I was looking for a way to remove all profiles of the previous MDM server via command line / script but didn't find one so I wrote one and thought i'd share...
#!/bin/bash
# Get a list from all profiles installed on the computer and remove every one of them
for identifier in $(profiles -L | awk "/attribute/" | awk '{print $4}')
do profiles -R -p $identifier
done
After this you can do sudo jamf manage mdm to get all the right profiles installed....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 03-21-2016 07:03 AM
Are the profiles installed by the JSS? If so, this should take care of it too. For whatever reason it's not documented.
sudo jamf removemdmprofile

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 03-21-2016 07:06 AM
Unfortunately, it was another MDM solution so that option would not help there. Thanks for sharing though.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 03-21-2016 08:23 AM
Have you seen whether this script can remove a profile that has the "remove-never" flag set in the General payload section under Security?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 03-21-2016 09:10 AM
Yes it will remove them, despite the error notice.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 03-21-2016 09:12 AM
I've been using the one below that I found searching around here:
!/bin/bash
Get UUID of requested MDM Profile
MDMUUID=profiles -Lv | grep "name: $4" -4 | awk -F": " '/attribute: profileIdentifier/{print $NF}'
Remove said profile, identified by UUID
if [[ $MDMUUID ]]; then
profiles -R -p $MDMUUID
else
echo "No Profile Found"
fi
sleep 5
I have a policy for each MDM profile installed by our previous management suite. Had good luck so far.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 03-21-2016 09:19 AM
When attaching a script be sure to use the >_ button and paste the script inside the quotes so that it preserves formatting.
#!/bin/sh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 05-11-2018 05:30 PM
#!/bin/sh
profiles remove -forced -all
