How to add an administrator without any administrators?
Recently when setting up a brand new Mac I accidentally set it up with the wrong admin user account name (it read my name from iCloud and used that which wasn't correct, and before I could cancel the account creation it'd already progressed).
I then went to System Preferences > Users & Groups, and by right clicking on the user account and going to "advanced" I changed the username, home folder, and a few other things. After doing this though, the user account became a "standard" account, instead of an administrator account.
So, somehow I managed to make my mac have zero administrator accounts. The preferences panel then locked itself, and I was unable to unlock it again because I didn't have the "administrator's password" as there aren't any administrator.
Right now I've taken the action to do a factory reset (CMD + R at boot) followed by a disk erasure, and a fresh install. Just doing the fresh install somehow kept all the data (including FileVault and the users O_o)
MacBook Pro TouchBar and Touch ID, macOS High Sierra (10.13.6)