Created
February 7, 2018 04:20
-
-
Save BernieWhite/0964f108e399a96db1e0347226c9eafb to your computer and use it in GitHub Desktop.
This file contains 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
# | |
# Domain Controller DSC Configuration | |
# | |
configuration dcConfigurationFile { | |
$domainName = Get-AutomationVariable -Name 'domainName'; | |
$adCredential = Get-AutomationPSCredential -Name 'domainAdmin'; | |
Import-DscResource -ModuleName xActiveDirectory, xComputerManagement, xNetworking, xStorage, PSDesiredStateConfiguration | |
Node 'newForest' { | |
# Add the DNS server feature | |
WindowsFeature DnsFeature { | |
Ensure = 'Present' | |
Name = 'DNS' | |
} | |
WindowsFeature DnsTools { | |
Ensure = 'Present' | |
Name = 'RSAT-DNS-Server' | |
} | |
# Setup loopback DNS address | |
xDnsServerAddress DnsServerAddress { | |
Address = '127.0.0.1' | |
InterfaceAlias = 'Ethernet 2' | |
AddressFamily = 'IPv4' | |
} | |
# Add Domain Services feature | |
WindowsFeature DomainServicesFeature { | |
Ensure = 'Present' | |
Name = 'AD-Domain-Services' | |
DependsOn = '[xDnsServerAddress]DnsServerAddress', '[WindowsFeature]DnsFeature' | |
} | |
# Install AD DS PowerShell cmdlets | |
WindowsFeature DomainServicesPSFeature { | |
Ensure = 'Present' | |
Name = 'RSAT-AD-PowerShell' | |
} | |
# Configure AD DS | |
xADDomain DomainController { | |
DomainName = $domainName | |
DomainAdministratorCredential = $adCredential | |
SafemodeAdministratorPassword = $adCredential | |
DatabasePath = 'F:\NTDS' | |
LogPath = 'F:\NTDS' | |
SysvolPath = 'F:\SYSVOL' | |
DependsOn = '[WindowsFeature]DomainServicesFeature', '[xDisk]Disk2' | |
} | |
xWaitforDisk WaitForDisk2 { | |
DiskId = 2 | |
RetryIntervalSec = 30 | |
RetryCount = 5 | |
} | |
xDisk Disk2 { | |
DiskId = 2 | |
DriveLetter = 'F' | |
DependsOn = '[xWaitForDisk]WaitForDisk2' | |
} | |
} | |
Node 'existingForest' { | |
# Add the DNS server feature | |
WindowsFeature DnsFeature { | |
Ensure = 'Present' | |
Name = 'DNS' | |
} | |
WindowsFeature DnsTools { | |
Ensure = 'Present' | |
Name = 'RSAT-DNS-Server' | |
} | |
# Setup loopback DNS address | |
xDnsServerAddress DnsServerAddress { | |
Address = '127.0.0.1' | |
InterfaceAlias = 'Ethernet 2' | |
AddressFamily = 'IPv4' | |
} | |
# Add Domain Services feature | |
WindowsFeature DomainServicesFeature { | |
Ensure = 'Present' | |
Name = 'AD-Domain-Services' | |
DependsOn = '[xDnsServerAddress]DnsServerAddress', '[WindowsFeature]DnsFeature' | |
} | |
# Install AD DS PowerShell cmdlets | |
WindowsFeature DomainServicesPSFeature { | |
Ensure = 'Present' | |
Name = 'RSAT-AD-PowerShell' | |
} | |
xADDomainController DomainController { | |
DomainName = $domainName | |
DomainAdministratorCredential = $adCredential | |
SafemodeAdministratorPassword = $adCredential | |
DatabasePath = 'F:\NTDS' | |
LogPath = 'F:\NTDS' | |
SysvolPath = 'F:\SYSVOL' | |
DependsOn = '[WindowsFeature]DomainServicesFeature', '[xDisk]Disk2' | |
} | |
xWaitforDisk WaitForDisk2 { | |
DiskId = 2 | |
RetryIntervalSec = 30 | |
RetryCount = 5 | |
} | |
xDisk Disk2 { | |
DiskId = 2 | |
DriveLetter = 'F' | |
DependsOn = '[xWaitForDisk]WaitForDisk2' | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment