Skip to content

Commit ac5acaa

Browse files
add migration sstandard for auth states
1 parent 85a094b commit ac5acaa

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
function Invoke-CIPPStandardAuthMethodsPolicyMigration {
2+
<#
3+
.FUNCTIONALITY
4+
Internal
5+
.COMPONENT
6+
(APIName) AuthMethodsPolicyMigration
7+
.SYNOPSIS
8+
(Label) Complete Authentication Methods Policy Migration
9+
.DESCRIPTION
10+
(Helptext) Completes the migration of authentication methods policy to the new format
11+
(DocsDescription) Sets the authentication methods policy migration state to complete. This is required when migrating from legacy authentication policies to the new unified authentication methods policy.
12+
.NOTES
13+
CAT
14+
Entra (AAD) Standards
15+
TAG
16+
ADDEDCOMPONENT
17+
IMPACT
18+
Medium Impact
19+
ADDEDDATE
20+
2025-01-08
21+
POWERSHELLEQUIVALENT
22+
Update-MgBetaPolicyAuthenticationMethodPolicy
23+
RECOMMENDEDBY
24+
UPDATECOMMENTBLOCK
25+
Run the Tools\Update-StandardsComments.ps1 script to update this comment block
26+
.LINK
27+
https://docs.cipp.app/user-documentation/tenant/standards/list-standards
28+
#>
29+
30+
param($Tenant, $Settings)
31+
$CurrentInfo = New-GraphGetRequest -uri 'https://graph.microsoft.com/beta/policies/authenticationMethodsPolicy' -tenantid $Tenant
32+
33+
if ($Settings.remediate -eq $true) {
34+
if ($CurrentInfo.policyMigrationState -eq 'migrationComplete') {
35+
Write-LogMessage -API 'Standards' -tenant $tenant -message 'Authentication methods policy migration is already complete.' -sev Info
36+
} else {
37+
try {
38+
New-GraphPOSTRequest -uri 'https://graph.microsoft.com/beta/policies/authenticationMethodsPolicy' -tenantid $Tenant -body '{"policyMigrationState": "migrationComplete"}' -type PATCH
39+
Write-LogMessage -API 'Standards' -tenant $tenant -message 'Authentication methods policy migration completed successfully.' -sev Info
40+
} catch {
41+
Write-LogMessage -API 'Standards' -tenant $tenant -message "Failed to complete authentication methods policy migration: $($_.Exception.Message)" -sev Error
42+
}
43+
}
44+
}
45+
46+
if ($Settings.alert -eq $true) {
47+
if ($CurrentInfo.policyMigrationState -ne 'migrationComplete') {
48+
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
49+
Write-LogMessage -API 'Standards' -tenant $tenant -message 'Authentication methods policy migration is not complete' -sev Alert
50+
}
51+
}
52+
53+
if ($Settings.report -eq $true) {
54+
$migrationComplete = $CurrentInfo.policyMigrationState -eq 'migrationComplete'
55+
Set-CIPPStandardsCompareField -FieldName 'standards.AuthMethodsPolicyMigration' -FieldValue $migrationComplete -TenantFilter $tenant
56+
Add-CIPPBPAField -FieldName 'AuthMethodsPolicyMigration' -FieldValue $migrationComplete -StoreAs bool -Tenant $tenant
57+
}
58+
59+
}

0 commit comments

Comments
 (0)