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
Thanks a lot for your detailed guide, I just tried to remove MDM for M2 MacBook with Ventura 13.6.1 and it works like a charm after some trial and errors. The caveat is to make sure that you wiped your internal disk before restoring the external one to the internal one. Some steps are failing for me for the first time so just reboot your computer when it doesn’t work and try it again. The first time when all the steps were completed, I got an error saying the macOS does not match the one Apple provides, so I just tried everything from scratch again. When trying to restore the disk, I often get the seal broken error and can to be fixed by actually booting into the system. For the last step when we do a “fresh” install and overwrite the disk, you can directly do it via the recovery menu, it doesn’t have to be installed from the external drive if the macOS version matches.
Thanks again for the nice guide and hope this comment is helpful for other people as well on this.