Hi Guys
i’m looking to automate my lab builds, so I figured i would start off with the Domain Controller. I wanted to include a dhcp server as well all on the same VM.
Everything in my configuration file is working AD, DNS all configure fine , no errors , BUT no DHCP server either .
Here is my config file
configuration NewDomain
{
param
(
[Parameter(Mandatory)]
[pscredential]$safemodeAdministratorCred,
[Parameter(Mandatory)]
[pscredential]$domainCred
)
Import-DscResource -ModuleName xActiveDirectory , xDHCpServer
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"
}
xDhcpServerScope Scope
{
Ensure = 'Present'
IPEndRange = '192.168.1.254'
IPStartRange = '192.168.1.1'
Name = 'PowerShellScope'
SubnetMask = '255.255.255.0'
LeaseDuration = '00:08:00'
State = 'Active'
AddressFamily = 'IPv4'
DependsOn = "[WindowsFeature]ADDSInstall","[File]ADFiles" , "[WindowsFeature]ADDSTools" , "[xADDomain]FirstDS"
}
}
}
##----------------------------------------------------------------------##
# Configuration Data for AD---------------------------------------------##
$ConfigData = @{
AllNodes = @(
@{
Nodename = "10.22.0.145"
Role = "Primary DC"
DomainName = "hcorp.local"
RetryCount = 20
RetryIntervalSec = 30
PsDscAllowPlainTextPassword = $true
}
)
}
##----------------------------------------------------------------------##
#Run Config Create MOFs
NewDomain -ConfigurationData $ConfigData `
-safemodeAdministratorCred (Get-Credential -UserName '(Password Only)' `
-Message "New Domain Safe Mode Administrator Password") `
-domainCred (Get-Credential -UserName 'hcorp\administrator' `
-Message "New Domain Admin Credential")