As with promoting a server to domain controller, demoting the a domain controller is also a straight forward process with PowerShell. The following PowerShell cmdlets are available from the ADDSDeployment module:
Uninstall Active Directory:
The demote process got a little tricky because this was the last DC in the domain and had an Operations Master role. I used two key parameters to bypass this situation:
Indicates that (forced) demotion should continue even if an operations master role is discovered on domain controller from which AD DS is
Forces the removal of a domain controller. Use this parameter to force the uninstall of AD DS if you need to remove the domain controller
and do not have connectivity to other domain controllers within the domain topology.
I uninstalled the Active Directory domain services role after the demotion :
After another restart, the server is clean and totally free of Active Directory.