Deleting Configuration Profiles through Terminal

Sometimes there’s a need to manually remove a configuration profile deployed by something like Apple’s Profile Manger; if for instance you cannot un-enroll the device, or you cannot access the ‘Profiles’ pane in System Preferences.

There’s a simple way I found to do this in Terminal.
The first command will list all the configuration profiles currently installed.
All these commands need to be run with sudo.

sudo profiles -P

This should present you with a list of all the profiles on the machine.
In my instance, I just wanted to delete all the ones installed, the following two commands will do this:

sudo profiles -d
sudo profiles -D

I found that after running these, some settings in the payloads of these profiles didn’t disappear, but a restart cleared that up completely.