dsclibrary/DC_SECONDARY.DSC.ps1
<###################################################################################################
DSC Template Configuration File For use by LabBuilder .Title DC_SECONDARY .Desription Builds a Domain Controller and adds it to the existing domain provided in the Parameter DomainName. Setting optional parameters Forwarders, ADZones and PrimaryZones will allow additional configuration of the DNS Server. .Parameters: DomainName = "LABBUILDER.COM" DomainAdminPassword = "P@ssword!1" PSDscAllowDomainUser = $true InstallRSATTools = $true Forwarders = @('8.8.8.8','8.8.4.4') ADZones = @( @{ Name = 'ALPHA.LOCAL'; DynamicUpdate = 'Secure'; ReplicationScope = 'Forest'; } ) PrimaryZones = @( @{ Name = 'BRAVO.LOCAL'; ZoneFile = 'bravo.local.dns'; DynamicUpdate = 'None'; } ) ###################################################################################################> Configuration DC_SECONDARY { Import-DscResource -ModuleName 'PSDesiredStateConfiguration' Import-DscResource -ModuleName xActiveDirectory Import-DscResource -ModuleName xDNSServer Node $AllNodes.NodeName { # Assemble the Local Admin Credentials if ($Node.LocalAdminPassword) { [PSCredential]$LocalAdminCredential = New-Object System.Management.Automation.PSCredential ("Administrator", (ConvertTo-SecureString $Node.LocalAdminPassword -AsPlainText -Force)) } if ($Node.DomainAdminPassword) { [PSCredential]$DomainAdminCredential = New-Object System.Management.Automation.PSCredential ("$($Node.DomainName)\Administrator", (ConvertTo-SecureString $Node.DomainAdminPassword -AsPlainText -Force)) } WindowsFeature BackupInstall { Ensure = "Present" Name = "Windows-Server-Backup" } WindowsFeature DNSInstall { Ensure = "Present" Name = "DNS" } WindowsFeature ADDSInstall { Ensure = "Present" Name = "AD-Domain-Services" DependsOn = "[WindowsFeature]DNSInstall" } WindowsFeature RSAT-AD-PowerShellInstall { Ensure = "Present" Name = "RSAT-AD-PowerShell" DependsOn = "[WindowsFeature]ADDSInstall" } if ($InstallRSATTools) { WindowsFeature RSAT-ManagementTools { Ensure = "Present" Name = "RSAT-AD-Tools","RSAT-DNS-Server" DependsOn = "[WindowsFeature]ADDSInstall" } } xWaitForADDomain DscDomainWait { DomainName = $Node.DomainName DomainUserCredential = $DomainAdminCredential RetryCount = 100 RetryIntervalSec = 10 DependsOn = "[WindowsFeature]ADDSInstall" } xADDomainController SecondaryDC { DomainName = $Node.DomainName DomainAdministratorCredential = $DomainAdminCredential SafemodeAdministratorPassword = $LocalAdminCredential DependsOn = "[xWaitForADDomain]DscDomainWait" } # DNS Server Settings if ($Node.Forwarders) { xDnsServerForwarder DNSForwarders { IsSingleInstance = 'Yes' IPAddresses = $Node.Forwarders DependsOn = "[xADDomainController]SecondaryDC" } } [System.Int32]$Count=0 Foreach ($ADZone in $Node.ADZones) { $Count++ xDnsServerADZone "ADZone$Count" { Ensure = 'Present' Name = $ADZone.Name DynamicUpdate = $ADZone.DynamicUpdate ReplicationScope = $ADZone.ReplicationScope DependsOn = "[xADDomainController]SecondaryDC" } } [System.Int32]$Count=0 Foreach ($PrimaryZone in $Node.PrimaryZones) { $Count++ xDnsServerPrimaryZone "PrimaryZone$Count" { Ensure = 'Present' Name = $PrimaryZone.Name ZoneFile = $PrimaryZone.ZoneFile DynamicUpdate = $PrimaryZone.DynamicUpdate DependsOn = "[xADDomainController]SecondaryDC" } } } } |