This isn’t a comprehensive “if you get this, these are all the solutions” post. This is more of a “this worked for me, and it may work for you, too” post.
If you’re using
sudo profiles renew -type enrollment to enroll a Mac in your MDM via DEP (or “automated device enrollment”), you may get this error message:
Enrollment with management server failed.
The MDM server for your organization returned an unexpected status (500).
One potential solution to this is to go to Apple Business Manager or Apple School Manager, unassign the Mac from the MDM, reassign the Mac to the MDM, and then run the
sudo profiles renew -type enrollment command again.
Your mileage may vary. Again, this is just a “this worked for me” post. If you comment “So I tried that, and it didn’t work. What else can I do?” I don’t know any more than anyone else what else to try. You’ll just have to Google that and see what other potential solutions/workarounds there are.