Good Evening,
I have a issue while creating multiple OUs and groups when using foreach. I am not sure if this is supported anymore.
I checked this site and I saw that this guy is creating multiple OUs and Groups with foreach
https://4sysops.com/archives/creating-an-active-directory-domain-with-powershell-dsc/
I have configuration data and in it I have like
DomainInfo = @{ ADOU = 'Windows Server 2016','Users','Servers','Computers' ADGroup1 = 'Group1','Group2','Group3','Group4' ADGroup2 = 'Berlin Users','Berlin Servers','Berlin Groups','Berlin Users' ADGroup3 = 'Hamburg Users','Hamburg Servers','Hamburg Users','Hamburg Groups' }
When it comes to the code I tried both his way (This is his code)
@($ConfigurationData.NonNodeData.OrganizationalUnits).foreach( { xADOrganizationalUnit $_ { Ensure = 'Present' Name = ($_ -replace '-') Path = ('DC={0},DC={1}' -f ($ConfigurationData.NonNodeData.DomainName -split '\.')[0], ($ConfigurationData.NonNodeData.DomainName -split '\.')[1]) DependsOn = '[xADDomain]ADDomain' } })
and I tried like this as well
foreach ($OU in $DCData.ADOrganizationalUnit) { xADOrganizationalUnit ADOU { Name = ($_ -replace '-') Path = $DomainInfo.DomainDN ProtectedFromAccidentalDeletion = $true DependsOn = '' } }
The result is the same. I get conflict error.
xActiveDirectory\xADOrganizationalUnit : A duplicate resource identifier…Change the name of this resource so that it is unique with
in the node specification.esources have identical key properties but there are differences in the following non-key properties: ‘DependsOn’. Values ‘NULL’ do
n’t match values ‘’. Please update these property values so that they are identical in both cases. I have no duplicated values, I have only 1 xADOrganizationalUnit
Can someone please help