Skip to content

Instantly share code, notes, and snippets.

@BernieWhite
Created February 7, 2018 04:20
Show Gist options
  • Save BernieWhite/0964f108e399a96db1e0347226c9eafb to your computer and use it in GitHub Desktop.
Save BernieWhite/0964f108e399a96db1e0347226c9eafb to your computer and use it in GitHub Desktop.
#
# 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