Created
September 19, 2016 10:24
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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