Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Import-Module ADDSDeployment
# Demote domain controller
$DomainName = "contoso.local"
$Cred = New-Object PSCredential "administrator@$DomainName",(ConvertTo-SecureString "P@ssw0rd" -AsPlainText -Force)
$Params = @{
LocalAdministratorPassword = (ConvertTo-SecureString "P@ssw0rd" -AsPlainText -Force);
DemoteOperationMasterRole = $true;
RemoveDnsDelegation = $true;
DnsDelegationRemovalCredential = $Cred;
Confirm = $false;
Uninstall-ADDSDomainController @Params
# Remove DNS
Remove-WindowsFeature DNS, RSAT-DNS-Server
# Remove ADDS
Remove-WindowsFeature AD-Domain-Services, GPMC, RSAT-ADDS, RSAT-AD-PowerShell
# Reboot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment