Skip to main content

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....

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

Unfortunately, it was another MDM solution so that option would not help there. Thanks for sharing though.


Have you seen whether this script can remove a profile that has the "remove-never" flag set in the General payload section under Security?


Yes it will remove them, despite the error notice.


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.


When attaching a script be sure to use the >_ button and paste the script inside the quotes so that it preserves formatting.



#!/bin/sh

#!/bin/sh
profiles remove -forced -all

Reply