Much simpler to use the GUI to remove.
https://techcommunity.microsoft.com/t5/itops-talk-blog/step-by-step-manually-removing-a-domain-controller-server/ba-p/280564
Make sure the MMC is connected to a healthy domain controller. Change Domain Controller if needed
--please don't forget to upvote
and Accept as answer
if the reply is helpful--