dsccommunity / ActiveDirectoryDsc

This module contains DSC resources for deployment and configuration of Active Directory Domain Services.
MIT License
336 stars 140 forks source link

Cannot create Tree domain with ADDomain Resource #692

Closed girvenj closed 7 months ago

girvenj commented 2 years ago

Problem description

Child domain works great, but I cannot create a tree in an existing forest with the ADDomain Resource

Verbose logs

PowerShell DSC resource MSFT_ADDomain  failed to execute Set-TargetResource functionality with error message: The 
running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: 
Verification of prerequisites for Domain Controller promotion failed. The child domain name "onpremisestree.local" has 
an invalid format. This name may contain letters, numbers, and hyphens, but not spaces or periods.
Characters that are not allowed include: ! " # $ % & ( ) * + , ' / : ; < = > ? @ [ \ ] ^ ` { | } ~

    + CategoryInfo          : InvalidOperation: (:) [], CimException
    + FullyQualifiedErrorId : ProviderOperationExecutionFailure
    + PSComputerName        : LocalHost

DSC configuration

'TreeDomainController' {
  ADDomain PrimaryDC {
      DomainName                    = $DomainDnsName
      DomainNetBIOSName             = $DomainNetBIOSName
      ParentDomainName              = $ParentDomainDNSName
      Credential                    = $EaCredentials
      SafemodeAdministratorPassword = $RestoreModeCredentials
      DatabasePath                  = 'D:\NTDS'
      LogPath                       = 'D:\NTDS'
      SysvolPath                    = 'D:\SYSVOL'
      DependsOn                     = '[User]AdministratorPassword'
  }

Suggested solution

Add "TreeDomain" as an options to install a domain into an exiting resource

https://github.com/dsccommunity/ActiveDirectoryDsc/blob/main/source/DSCResources/MSFT_ADDomain/MSFT_ADDomain.psm1#L477

Operating system the target node is running

OsName               : Microsoft Windows Server 2022 Datacenter
OsOperatingSystemSKU : DatacenterServerEdition
OsArchitecture       : 64-bit
WindowsVersion       : 2009
WindowsBuildLabEx    : 20348.1.amd64fre.fe_release.210507-1500
OsLanguage           : en-US
OsMuiLanguages       : {en-US}

PowerShell version and build the target node is running

Name                           Value
----                           -----
PSVersion                      5.1.20348.643
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.20348.643
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

ActiveDirectoryDsc version

Name               Version Path
----               ------- ----
ActiveDirectoryDsc 6.0.1   C:\Program Files\WindowsPowerShell\Modules\ActiveDirectoryDsc\6.0.1\ActiveDirectoryDsc.psd1
johlju commented 2 years ago

This is also tracked in #689.