Handle absent AD role groups during deployment

This commit is contained in:
2026-09-08 11:37:35 -06:00
parent 7a4f599f55
commit 1fe2006404
+6 -1
View File
@@ -140,7 +140,12 @@ foreach ($definition in $roleGroupDefinitions) {
throw "$($definition.Role)GroupDn must identify a security group beneath BaseDn." 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) { if (-not $roleGroup -and $CreateMissingOus) {
$groupDnMatch = [regex]::Match($definition.Dn, '^CN=(?<Name>[^,]+),(?<Path>.+)$', [Text.RegularExpressions.RegexOptions]::IgnoreCase) $groupDnMatch = [regex]::Match($definition.Dn, '^CN=(?<Name>[^,]+),(?<Path>.+)$', [Text.RegularExpressions.RegexOptions]::IgnoreCase)
if (-not $groupDnMatch.Success) { if (-not $groupDnMatch.Success) {