Skip to content

Commit 0345b5c

Browse files
Merge pull request #1567 from ngms-psh/fix-AuthMethodsPolicyMigration-alert
Fix: AuthMethodsPolicyMigration for newer tenants
2 parents 186ec9f + cffa2d1 commit 0345b5c

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

Modules/CIPPCore/Public/Standards/Invoke-CIPPStandardAuthMethodsPolicyMigration.ps1

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,12 @@ function Invoke-CIPPStandardAuthMethodsPolicyMigration {
3030
param($Tenant, $Settings)
3131
$CurrentInfo = New-GraphGetRequest -uri 'https://graph.microsoft.com/beta/policies/authenticationMethodsPolicy' -tenantid $Tenant
3232

33+
if ($null -eq $CurrentInfo) {
34+
throw "Failed to retrieve current authentication methods policy information"
35+
}
36+
3337
if ($Settings.remediate -eq $true) {
34-
if ($CurrentInfo.policyMigrationState -eq 'migrationComplete') {
38+
if ($CurrentInfo.policyMigrationState -eq 'migrationComplete' -or $null -eq $CurrentInfo.policyMigrationState) {
3539
Write-LogMessage -API 'Standards' -tenant $tenant -message 'Authentication methods policy migration is already complete.' -sev Info
3640
} else {
3741
try {
@@ -44,14 +48,14 @@ function Invoke-CIPPStandardAuthMethodsPolicyMigration {
4448
}
4549

4650
if ($Settings.alert -eq $true) {
47-
if ($CurrentInfo.policyMigrationState -ne 'migrationComplete') {
51+
if ($CurrentInfo.policyMigrationState -ne 'migrationComplete' -and $null -ne $CurrentInfo.policyMigrationState) {
4852
Write-StandardsAlert -message 'Authentication methods policy migration is not complete. Please check if you have legacy SSPR settings or MFA settings set: https://learn.microsoft.com/en-us/entra/identity/authentication/how-to-authentication-methods-manage' -object $CurrentInfo -tenant $tenant -standardName 'AuthMethodsPolicyMigration' -standardId $Settings.standardId
4953
Write-LogMessage -API 'Standards' -tenant $tenant -message 'Authentication methods policy migration is not complete' -sev Alert
5054
}
5155
}
5256

5357
if ($Settings.report -eq $true) {
54-
$migrationComplete = $CurrentInfo.policyMigrationState -eq 'migrationComplete'
58+
$migrationComplete = $CurrentInfo.policyMigrationState -eq 'migrationComplete' -or $null -eq $CurrentInfo.policyMigrationState
5559
Set-CIPPStandardsCompareField -FieldName 'standards.AuthMethodsPolicyMigration' -FieldValue $migrationComplete -TenantFilter $tenant
5660
Add-CIPPBPAField -FieldName 'AuthMethodsPolicyMigration' -FieldValue $migrationComplete -StoreAs bool -Tenant $tenant
5761
}

0 commit comments

Comments
 (0)