Skip to content

Instantly share code, notes, and snippets.

@jcotton42
Last active August 29, 2015 14:04
Show Gist options
  • Save jcotton42/9917c30d386698ab520c to your computer and use it in GitHub Desktop.
Save jcotton42/9917c30d386698ab520c to your computer and use it in GitHub Desktop.
DSC Domain Config
Set-StrictMode -Off # DSC doesn't seem to like strict mode...
#[DscLocalConfigurationManager()] # CertificateID is broken in the new LCM config type, will try again w/ next PS5 CTP
Configuration DomainLCM {
Node $AllNodes.NodeName {
LocalConfigurationManager {
CertificateID = $Node.Thumbprint
RebootNodeIfNeeded = $true
}
}
}
Configuration Domain {
param(
[pscredential]$DomainCredential,
[pscredential]$DSRMCredential
)
Import-DscResource -Module xActiveDirectory,xComputerManagement
Node $AllNodes.Where({$_.Role -eq 'DC'}).NodeName {
WindowsFeature ADDS {
Ensure = 'Present'
Name = 'AD-Domain-Services'
}
xADDomain WebDomain {
DependsOn = '[WindowsFeature]ADDS'
DomainName = $ConfigurationData.DomainName
DomainAdministratorCredential = $DomainCredential
SafemodeAdministratorPassword = $DSRMCredential
}
}
Node $AllNodes.Where({$_.Role -eq 'Client'}).NodeName {
WaitForAny DC {
ResourceName = '[xADDomain]WebDomain'
NodeName = $AllNodes.Where({$_.Role -eq 'DC'}).NodeName
RetryIntervalSec = 15
RetryCount = 30
Credential = $DomainCredential
}
xComputer JoinDomain {
DependsOn = '[WaitForAny]DC'
Name = $Node.NodeName
DomainName = $ConfigurationData.DomainName
Credential = $DomainCredential
}
}
}
$ConfigData = @{
AllNodes = @(
@{
NodeName = '*'
CertificateFile = "$PSScriptRoot\Web-DSC.cer"
Thumbprint = 'D1AF24BE374BBBA21391DB623B69A01F3C070A34'
},
@{
NodeName = 'DC1'
Role = 'DC'
},
@{
NodeName = 'Client1'
Role = 'Client'
}
)
DomainName = 'web.jcotton.net'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment