Handle absent AD role groups during deployment
This commit is contained in:
@@ -140,7 +140,12 @@ foreach ($definition in $roleGroupDefinitions) {
|
||||
throw "$($definition.Role)GroupDn must identify a security group beneath BaseDn."
|
||||
}
|
||||
|
||||
$roleGroup = Get-ADGroup -Identity $definition.Dn -Server $LdapHost -ErrorAction SilentlyContinue
|
||||
try {
|
||||
$roleGroup = Get-ADGroup -Identity $definition.Dn -Server $LdapHost -ErrorAction Stop
|
||||
}
|
||||
catch [Microsoft.ActiveDirectory.Management.ADIdentityNotFoundException] {
|
||||
$roleGroup = $null
|
||||
}
|
||||
if (-not $roleGroup -and $CreateMissingOus) {
|
||||
$groupDnMatch = [regex]::Match($definition.Dn, '^CN=(?<Name>[^,]+),(?<Path>.+)$', [Text.RegularExpressions.RegexOptions]::IgnoreCase)
|
||||
if (-not $groupDnMatch.Success) {
|
||||
|
||||
Reference in New Issue
Block a user