Skip to content

Instantly share code, notes, and snippets.

@BernieWhite
Created January 18, 2018 23:18
Show Gist options
  • Save BernieWhite/495ab488626ac53d1ce2061232acb9bf to your computer and use it in GitHub Desktop.
Save BernieWhite/495ab488626ac53d1ce2061232acb9bf to your computer and use it in GitHub Desktop.
#
# Domain Controller DSC Configuration
#
configuration dcConfiguration {
$domainName = Get-AutomationVariable -Name 'domainName';
$adCredential = Get-AutomationPSCredential -Name 'domainAdmin';
Import-DscResource -ModuleName xActiveDirectory, xComputerManagement, xNetworking, xStorage, PSDesiredStateConfiguration
Node $AllNodes.NodeName {
# 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'
}
if ($Node.CreateForest) {
# 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'
}
}
else {
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