Search
Windows Server

Windows Server 2008 : Promoting and Demoting a Domain Controller - Demoting a DC with dcpromo, Using dcpromo with an unattend File

Published 2 min readBy Programming4us Editorial Team

1. Demoting a DC with dcpromo

If you run dcpromo on a DC, it recognizes that the computer is already a DC hosting Active Directory. It then prompts you to remove Active Directory. The following steps show how to remove Active Directory from the last domain controller in a domain.

StepAction
1.Launch a command prompt with administrative permissions.
2.Type dcpromo at the command prompt and press Enter.
3.When the Welcome screen displays, click Next.
4.A warning appears indicating the server is a Global Catalog server and recommending you ensure that you have at least one Global Catalog server in the domain. Click OK.
5.On the Delete the Domain page, select the checkbox to delete the domain, as shown in Figure 1. Click Next.
6.If the DC uses Active Directory Integrated DNS, a dialog box displays, indicating what partitions are installed on the DC and letting you know they’ll be removed. Click Next.
7.On the Confirm Deletion page, select the checkbox to Delete All Application Directory Partitions on this Active Directory Domain Controller. Click Next.
8.Type the password for the local Administrator account in the Password and Confirm Password text boxes. Click Next.
9.Review the information on the Summary page and click Next. Select the checkbox to Reboot on Completion. When dcpromo completes, it automatically reboots as a standalone server.

Figure 1. Using dcpromo to remove the last DC in the domain


2. Using dcpromo with an unattend File

One benefit of launching dcpromo from the command line is that you can automate the installation with an unattend file. The easiest way to create an answer file is with the dcpromo wizard. You can run it on any non-DC server but when you get to the Summary page, click the Export Settings button to create the answer file.

The following code shows the contents of an answer file created from the earlier installation.

Note

You can create this file from scratch within Notepad, but it is much easier to let the wizard create it for you.


Code View: Scroll / Show All

; DCPROMO unattend file (automatically generated by dcpromo)
; Usage:
;   dcpromo.exe /unattend:C:\data\unattend.txt
;
[DCInstall]
; New forest promotion
ReplicaOrNewDomain=Domain
NewDomain=Forest
NewDomainDNSName=pearson.pub
ForestLevel=2
DomainNetbiosName=PEARSON
DomainLevel=2
InstallDNS=Yes
ConfirmGc=Yes
CreateDNSDelegation=No
DatabasePath="C:\Windows\NTDS"
LogPath="C:\Windows\NTDS"
SYSVOLPath="C:\Windows\SYSVOL"
; Set SafeModeAdminPassword to the correct value prior to
  using the unattend file
SafeModeAdminPassword=
; Run-time flags (optional)
; RebootOnCompletion=Yes

					  

Note

Comments in the unattend file are annotated with a semicolon (;). These lines are ignored by the dcpromo wizard.


Notice that the command to use it is embedded as a comment on the third line. This line points to the location where the unattend.txt file was saved (c:\data in this example).

You must change the SafeModeAdminPassword= line by adding the password you want to assign for Directory Services Restore Mode:

SafeModeAdminPassword=P@ssw0rd

After you add the password and save the file, you can use the following command to run dcpromo with the answer file:

dcpromo.exe /unattend:C:\data\unattend.txt

Note

You might need to use a different path depending on where the unattend.txt file is located.


No other user interaction is necessary. dcpromo completes and reboots the server. When it reboots, it will be a domain controller.