Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@nivleshc
Created September 19, 2016 10:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nivleshc/5174735d048b0e7df5e5c83de664a8b9 to your computer and use it in GitHub Desktop.
Save nivleshc/5174735d048b0e7df5e5c83de664a8b9 to your computer and use it in GitHub Desktop.
DSC Configuration script to add a replica DC to an existing Active Directory Domain
Configuration CreateADReplicaDC
{
param
(
[Parameter(Mandatory)][String]$DomainName,
[Parameter(Mandatory)]
[System.Management.Automation.PSCredential]$Admincreds,
[Parameter(Mandatory)]
[System.Management.Automation.PSCredential]$SafemodeAdminCreds,
[Int]$RetryCount=20,
[Int]$RetryIntervalSec=30
)
Import-DscResource -ModuleName xActiveDirectory, xPendingReboot
[System.Management.Automation.PSCredential]$DomainCreds = New-Object System.Management.Automation.PSCredential ("${DomainName}\$($Admincreds.UserName)", $Admincreds.Password)
Node localhost
{
LocalConfigurationManager
{
ActionAfterReboot = 'ContinueConfiguration'
ConfigurationMode = 'ApplyOnly'
RebootNodeIfNeeded = $true
}
WindowsFeature RSAT
{
Ensure = "Present"
Name = "RSAT"
}
WindowsFeature ADDSInstall
{
Ensure = "Present"
Name = "AD-Domain-Services"
}
xWaitForADDomain DscForestWait
{
DomainName = $DomainName
DomainUserCredential= $DomainCreds
RetryCount = $RetryCount
RetryIntervalSec = $RetryIntervalSec
DependsOn = "[WindowsFeature]ADDSInstall"
}
xADDomainController ReplicaDC
{
DomainName = $DomainName
DomainAdministratorCredential = $DomainCreds
SafemodeAdministratorPassword = $SafeModeAdminCreds
DatabasePath = "C:\NTDS"
LogPath = "C:\NTDS"
SysvolPath = "C:\SYSVOL"
DependsOn = "[xWaitForADDomain]DScForestWait"
}
xPendingReboot Reboot1
{
Name = "RebootServer"
DependsOn = "[xADDomainController]ReplicaDC"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment