AADPasswordRuleSettings - BannedPasswordCheckOnPremisesMode error
Description of the issue
When Trying to deploy AADPasswordRuleSettings configuration I get :
Verbose logs showing the problem
[Request_BadRequest] : The expected property 'BannedPasswordCheckOnPremisesMode'
defined in template with SettingTemplateId '5cf42378-d67d-4f36-ba46-e8b86229381d'
was not provided. paramName: BannedPasswordCheckOnPremisesMode, paramValue:
System.String, objectType:
Microsoft.Online.DirectoryServices.ObjectSettingTemplate
+ CategoryInfo : InvalidOperation: ({ Headers = , b...ectorySetting
}:) [], CimException
+ FullyQualifiedErrorId : Request_BadRequest,Microsoft.Graph.Beta.PowerShell.
Cmdlets.NewMgBetaDirectorySetting_CreateExpanded
+ PSComputerName : localhost
Problem was fixed by updating "C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\1.24.1016.1\DSCResources\MSFT_AADPasswordRuleSettings\MSFT_AADPasswordRuleSettings.psm1"
It appeared that $Policy was still empty after execution of
$Policy = New-MgBetaDirectorySetting -TemplateId '5cf42378-d67d-4f36-ba46-e8b86229381d' | Out-Null
Workaround (quick and dirty, to improve)
1- create "params" BodyParameter
2 - replace
$Policy = New-MgBetaDirectorySetting -TemplateId '5cf42378-d67d-4f36-ba46-e8b86229381d'
by
$Policy = New-MgBetaDirectorySetting -TemplateId $params.templateid -Values $params.values
$params = @{
templateId = "5cf42378-d67d-4f36-ba46-e8b86229381d"
values = @(
@{
name = "LockoutThreshold"
value = $LockoutThreshold
},
@{
name = "LockoutDurationInSeconds"
value = $LockoutDurationInSeconds
},
@{
name = "EnableBannedPasswordCheck"
value = [System.Boolean]$EnableBannedPasswordCheck
},
@{
name = "BannedPasswordList"
value = $BannedPasswordList -join "`t"
},
@{
name = "EnableBannedPasswordCheckOnPremises"
value = [System.Boolean]$EnableBannedPasswordCheckOnPremises
},
@{
name = "BannedPasswordCheckOnPremisesMode"
value = $BannedPasswordCheckOnPremisesMode
}
)
}
# Policy should exist but it doesn't
$needToUpdate = $false
if ($Ensure -eq 'Present' -and $currentPolicy.Ensure -eq 'Absent')
{
#$template = Get-MgBetaDirectorySettingTemplate -All | Where-Object -FilterScript {$_.Displayname -eq 'Password Rule Settings'}
write-verbose -message "New-MgBetaDirectorySetting"
$Policy = New-MgBetaDirectorySetting -TemplateId $params.templateid -Values $params.values
$needToUpdate = $true
}
Microsoft 365 DSC Version
1.24.1016.1
Which workloads are affected
AADPasswordRuleSettings
Environment Information + PowerShell Version
OsName : Microsoft Windows Server 2022 Standard
OsOperatingSystemSKU : StandardServerEdition
OsArchitecture : 64-bit
OsLanguage : en-US
OsMuiLanguages : {en-US}
Version : 7.4.5
InstanceId : d6fb8fed-d531-4c5b-81e3-6155644646c5
UI : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture : fr-FR
CurrentUICulture : en-US
PrivateData : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
DebuggerEnabled : True
IsRunspacePushed : False
Runspace : System.Management.Automation.Runspaces.LocalRunspace
The error is still present in the current version it seems.
Hello,
I have found a solution. It's important to pay attention to the formatting at several points. I hope this helps you in solving the issue:
important:
- ..... OnPremisesMode'; Value = "'Audit'"
- ..... onInSeconds'; Value = "'50'"
- ..... old'; Value = "'20'"
- ..... $bannedPasswords -join [char]9
# Korrektur der Banned Passwords (alle Passwörter haben zwischen 4 und 16 Zeichen)
$bannedPasswords = "start123", "knwdkj", "kjwdnjdw" # Alle Passwörter
# Erstelle das PowerShell-Objekt mit den Verzeichniseinstellungen
$setting = @{
ID = "030bea03-ee2d-4f42-9347-7db1169a82d5"
values = @(
@{ Name = 'BannedPasswordCheckOnPremisesMode'; Value = "'Audit'" },
@{ Name = 'EnableBannedPasswordCheckOnPremises'; Value = 'True' },
@{ Name = 'EnableBannedPasswordCheck'; Value = 'True' },
@{ Name = 'LockoutDurationInSeconds'; Value = "'50'" },
@{ Name = 'LockoutThreshold'; Value = "'20'" },
@{ Name = 'BannedPasswordList'; Value = $bannedPasswords -join [char]9 } # Die Passwörter werden mit Leerzeichen getrennt
)
}
# Führe das Update durch
Update-MgBetaDirectorySetting -DirectorySettingId $setting.ID -Values $setting.values
Does the issue occur even now or is it fixed? There was an issue with serialization in the last versions.
Closing this. If the issue persists, feel free to reopen it.