Install Primary and Additional Domain Controller With PowerShell Cheat Sheet

# Windows PowerShell script for AD DS Deployment
#Do no forget to rename the computer, set static IP, enable remote desktop if needed and so on
Install-WindowsFeature AD-Domain-Services
Install-ADDSForest `
-CreateDnsDelegation:$false `
-DatabasePath “C:\Windows\NTDS” `
-DomainMode “Win2012” `
-DomainName “” `
-DomainNetbiosName “DOMAIN” `
-ForestMode “Win2012” `
-InstallDns:$true `
-LogPath “C:\Windows\NTDS” `
-NoRebootOnCompletion:$false `
-SysvolPath “C:\Windows\SYSVOL” `

#Add Secondary DC

# Do not forget to rename the computer first
Rename-Computer -NewName whatever
#Set Static IP and DNS
#Could be done with interface index as well
#get-wmiobject win32_networkadapter | select netconnectionid, name, InterfaceIndex, netconnectionstatus
#netconnection status 2 gives us only connected adapters 🙂

New-NetIPAddress -InterfaceAlias Ethernet -IPAddress YOURSERVERIP  -DefaultGateway GATEWAYIP -AddressFamily IPv4 -PrefixLength 24
Set-DnsClientServerAddress -InterfaceAlias Ethernet -ServerAddresses DNSADRESS1, DNSADRRESS2

#Enable Remote Desktop via sconfig.cmd or your preferred way
#Reboot Now
#Join The Domain

Add-Computer -ComputerName SERVERNAME -DomainName DOMAINNAME -Credential domain\admin -Restart

#Install Secondary DC

Install-WindowsFeature AD-Domain-Services -IncludeManagementTools
Install-ADDSDomainController -DomainName “” -credential $(get-credential)

#Management Tools Inluded here, but if they are not needed, just remove them
SafeModeAdministratorPassword is needed
#Check Replication

Get-ADReplicationFailure -scope SITE -target Default-First-Site-Name | FT Server, FirstFailureTime, FailureClount, LastError, Partner -AUTO
Get-ADReplicationPartnerMetadata -Target * -Partition * | Select-Object Server,Partition,Partner,ConsecutiveReplicationFailures,LastReplicationSuccess,LastRepicationResult

That’s All


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.