Skip to content

Instantly share code, notes, and snippets.

@bobalob
Created December 1, 2016 14:04
Show Gist options
  • Save bobalob/a7f2cb19da6fae8b1383b99359edd92c to your computer and use it in GitHub Desktop.
Save bobalob/a7f2cb19da6fae8b1383b99359edd92c to your computer and use it in GitHub Desktop.
configuration NewDomain
{
param
(
[Parameter(Mandatory)]
[pscredential]$safemodeAdministratorCred,
[Parameter(Mandatory)]
[pscredential]$domainCred
)
Import-DscResource -ModuleName PSDesiredStateConfiguration
Import-DscResource -ModuleName xActiveDirectory
Node $AllNodes.Where{$_.Role -eq "Primary DC"}.Nodename
{
LocalConfigurationManager
{
ActionAfterReboot = 'ContinueConfiguration'
ConfigurationMode = 'ApplyOnly'
RebootNodeIfNeeded = $true
}
File ADFiles
{
DestinationPath = 'C:\NTDS'
Type = 'Directory'
Ensure = 'Present'
}
WindowsFeature ADDSInstall
{
Ensure = "Present"
Name = "AD-Domain-Services"
}
# Optional GUI tools
WindowsFeature ADDSTools
{
Ensure = "Present"
Name = "RSAT-ADDS"
}
# No slash at end of folder paths
xADDomain FirstDS
{
DomainName = $Node.DomainName
DomainAdministratorCredential = $domainCred
SafemodeAdministratorPassword = $safemodeAdministratorCred
DatabasePath = 'C:\NTDS'
LogPath = 'C:\NTDS'
DependsOn = "[WindowsFeature]ADDSInstall","[File]ADFiles"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment