Ventura docs for M2 Macs in this comment: https://gist.github.com/henrik242/65d26a7deca30bdb9828e183809690bd?permalink_comment_id=4555340#gistcomment-4555340
Old Monterey docs in this old revision: https://gist.github.com/henrik242/65d26a7deca30bdb9828e183809690bd/32c410e3a1de73539c76fa13ea5486569c4e0c5d
Solution for Sonoma: https://gist.github.com/sghiassy/a3927405cf4ffe81242f4ecb01c382ac
Im no expert, but I added one more entry in my host file. Hope this helps
STEP 1: open terminal and type:
sudo profiles show -type enrollment (press enter)
Type in your password.
This will show you the current enrollment configuration your Mac has
.
STEP 2: copy the domain mentioned in "ConfigurationURL" by selecting the address without the (").
STEP 3: type:
sudo pico /etc/hosts (press enter)
Type in your password
you should see something like this...
.##
.# Host Database
.#
.# localhost is used to configure the loopback interface
.# when the system is booting. Do not change this entry.
127.0.0.1 localhost
... broadcasthost
::1 localhost
STEP 4: use your arrow key to go down to the bottom, press "return" twice and type:
127.0.0.1 iprofiles.apple.com (press enter) and you are about to paste the configuration url copied in step 2. 127.0.0.1 paste the "ConfigurationURL" you copied in step 2 (press enter)
Below is an example of what it looks like in my case...
.##
.# Host Database
.#
.# localhost is used to configure the loopback interface
.# when the system is booting. Do not change this entry.
.##
127.0.0.1 localhost
... broadcasthost
::1 localhost
127.0.0.1 iprofiles.apple.com
127.0.0.1 https://jss.client-******************
Use control+ O to write then the "Return" key so that it writes over that file, then control+ X to exit.
STEP 5: Clear the cache by typing:
sudo dscacheutil -flushcache (press enter)
STEP 6: proceed to delete the profile by typing:
sudo profiles remove -all
Keep in mind that this command will delete all other profiles you may have. Finally, you can check for the enrollment profile again (STEP 1), you should get an error saying that it could not be retrieved given that you blocked the domain from where it's retrieved:
sudo profiles show -type enrollment
Error fetching Device Enrollment configuration: (34000) Error Domain=MCCloudConfigurationErrorDomain Code=34000 "The device failed to request configuration from the cloud." UserInfo={NSLocalizedDescription=The device failed to request configuration from the cloud., CloudConfigurationErrorType=CloudConfigurationFatalError}
And the notification is gone for good.