# Erstelle OUs in OUS und gleichnamige Gruppen
$ous = @(("IT_Entwicklung","Essen"),("IT_Test","Bochum")) foreach($ou in $ous) { [string] $Path = "OU=$($ous[0]),DC=ndsedv,DC=de" if(![adsi]::Exists("LDAP://$Path")) { $newou = New-ADOrganizationalUnit -Name $ou[0] -Path "OU=ORG,DC=ndsedv,DC=de" -Description $ou[1] -ProtectedFromAccidentalDeletion $false -PassThru $ouGroups=New-ADOrganizationalUnit -Name "Gruppen" -Path $newou.DistinguishedName ` -Description "Gruppen" ` -ProtectedFromAccidentalDeletion $false -PassThru } $AdminGroupName = "$($ou[0])" $AdminGroup = New-ADGroup -Name $AdminGroupName -GroupCategory Security -GroupScope Global ` -DisplayName $AdminGroupName -Path $ouGroups.DistinguishedName ` -Description "Delegated Administrators for OU $($ou[0])" -PassThru }
Download Skript: