|
| 1 | +function Invoke-CIPPStandardAdminSSPR { |
| 2 | + <# |
| 3 | + .FUNCTIONALITY |
| 4 | + Internal |
| 5 | + .COMPONENT |
| 6 | + (APIName) AdminSSPR |
| 7 | + .SYNOPSIS |
| 8 | + (Label) Set administrator Self-Service Password Reset state |
| 9 | + .DESCRIPTION |
| 10 | + (Helptext) Controls whether administrators are allowed to use Self-Service Password Reset through the Microsoft Entra authorization policy. |
| 11 | + (DocsDescription) Configures the allowedToUseSSPR property on the Microsoft Entra authorization policy. Microsoft documents this property as controlling whether administrators of the tenant can use Self-Service Password Reset. Use this standard to explicitly enable or disable administrator SSPR based on your security policy. |
| 12 | + .NOTES |
| 13 | + CAT |
| 14 | + Entra (AAD) Standards |
| 15 | + TAG |
| 16 | + "EIDSCA.AP01" |
| 17 | + "EIDSCAAP01" |
| 18 | + "ZTNA21842" |
| 19 | + EXECUTIVETEXT |
| 20 | + Controls whether tenant administrators can reset their own passwords through Self-Service Password Reset. Disabling this capability forces privileged accounts through more controlled recovery processes and reduces the risk of self-service recovery being misused on administrative identities. |
| 21 | + ADDEDCOMPONENT |
| 22 | + {"type":"autoComplete","multiple":false,"creatable":false,"label":"Select value","name":"standards.AdminSSPR.state","options":[{"label":"Enabled","value":"enabled"},{"label":"Disabled","value":"disabled"}]} |
| 23 | + IMPACT |
| 24 | + Low Impact |
| 25 | + ADDEDDATE |
| 26 | + 2026-04-21 |
| 27 | + POWERSHELLEQUIVALENT |
| 28 | + Update-MgBetaPolicyAuthorizationPolicy |
| 29 | + RECOMMENDEDBY |
| 30 | + "CIPP" |
| 31 | + UPDATECOMMENTBLOCK |
| 32 | + Run the Tools\Update-StandardsComments.ps1 script to update this comment block |
| 33 | + .LINK |
| 34 | + https://docs.cipp.app/user-documentation/tenant/standards/list-standards |
| 35 | + #> |
| 36 | + |
| 37 | + param($Tenant, $Settings) |
| 38 | + |
| 39 | + $StateValue = $Settings.state.value ?? $Settings.state |
| 40 | + if ([string]::IsNullOrWhiteSpace($StateValue)) { |
| 41 | + Write-LogMessage -API 'Standards' -tenant $Tenant -message 'AdminSSPR: Invalid state parameter set.' -sev Error |
| 42 | + return |
| 43 | + } |
| 44 | + |
| 45 | + switch ($StateValue.ToLowerInvariant()) { |
| 46 | + 'enabled' { |
| 47 | + $DesiredValue = $true |
| 48 | + $DesiredLabel = 'enabled' |
| 49 | + } |
| 50 | + 'disabled' { |
| 51 | + $DesiredValue = $false |
| 52 | + $DesiredLabel = 'disabled' |
| 53 | + } |
| 54 | + default { |
| 55 | + Write-LogMessage -API 'Standards' -tenant $Tenant -message "AdminSSPR: Unsupported state value '$StateValue'." -sev Error |
| 56 | + return |
| 57 | + } |
| 58 | + } |
| 59 | + |
| 60 | + try { |
| 61 | + $CurrentState = New-GraphGetRequest -Uri 'https://graph.microsoft.com/beta/policies/authorizationPolicy/authorizationPolicy' -tenantid $Tenant |
| 62 | + } catch { |
| 63 | + $ErrorMessage = Get-CippException -Exception $_ |
| 64 | + Write-LogMessage -API 'Standards' -tenant $Tenant -message "Could not get the AdminSSPR state for $Tenant. Error: $($ErrorMessage.NormalizedError)" -sev Error -LogData $ErrorMessage |
| 65 | + return |
| 66 | + } |
| 67 | + |
| 68 | + $CurrentStateValue = [bool]$CurrentState.allowedToUseSSPR |
| 69 | + $StateIsCorrect = ($CurrentStateValue -eq $DesiredValue) |
| 70 | + |
| 71 | + $CurrentValue = [PSCustomObject]@{ |
| 72 | + allowedToUseSSPR = $CurrentStateValue |
| 73 | + } |
| 74 | + $ExpectedValue = [PSCustomObject]@{ |
| 75 | + allowedToUseSSPR = $DesiredValue |
| 76 | + } |
| 77 | + |
| 78 | + if ($Settings.remediate -eq $true) { |
| 79 | + if ($StateIsCorrect -eq $true) { |
| 80 | + Write-LogMessage -API 'Standards' -tenant $Tenant -message "Administrator SSPR is already $DesiredLabel." -sev Info |
| 81 | + } else { |
| 82 | + try { |
| 83 | + $Body = @{ allowedToUseSSPR = $DesiredValue } | ConvertTo-Json -Compress -Depth 10 |
| 84 | + $null = New-GraphPOSTRequest -Uri 'https://graph.microsoft.com/beta/policies/authorizationPolicy/authorizationPolicy' -tenantid $Tenant -Type PATCH -Body $Body |
| 85 | + Write-LogMessage -API 'Standards' -tenant $Tenant -message "Successfully set administrator SSPR to $DesiredLabel." -sev Info |
| 86 | + |
| 87 | + $CurrentState.allowedToUseSSPR = $DesiredValue |
| 88 | + $CurrentStateValue = $DesiredValue |
| 89 | + $StateIsCorrect = $true |
| 90 | + } catch { |
| 91 | + $ErrorMessage = Get-CippException -Exception $_ |
| 92 | + Write-LogMessage -API 'Standards' -tenant $Tenant -message "Failed to set administrator SSPR to $DesiredLabel. Error: $($ErrorMessage.NormalizedError)" -sev Error -LogData $ErrorMessage |
| 93 | + } |
| 94 | + } |
| 95 | + } |
| 96 | + |
| 97 | + if ($Settings.alert -eq $true) { |
| 98 | + if ($StateIsCorrect -eq $true) { |
| 99 | + Write-LogMessage -API 'Standards' -tenant $Tenant -message "Administrator SSPR is $DesiredLabel as configured." -sev Info |
| 100 | + } else { |
| 101 | + $CurrentLabel = if ($CurrentStateValue) { 'enabled' } else { 'disabled' } |
| 102 | + $AlertMessage = "Administrator SSPR is currently $CurrentLabel but should be $DesiredLabel." |
| 103 | + Write-StandardsAlert -message $AlertMessage -object $CurrentState -tenant $Tenant -standardName 'AdminSSPR' -standardId $Settings.standardId |
| 104 | + Write-LogMessage -API 'Standards' -tenant $Tenant -message $AlertMessage -sev Info |
| 105 | + } |
| 106 | + } |
| 107 | + |
| 108 | + if ($Settings.report -eq $true) { |
| 109 | + Set-CIPPStandardsCompareField -FieldName 'standards.AdminSSPR' -CurrentValue $CurrentValue -ExpectedValue $ExpectedValue -TenantFilter $Tenant |
| 110 | + Add-CIPPBPAField -FieldName 'AdminSSPR' -FieldValue $StateIsCorrect -StoreAs bool -Tenant $Tenant |
| 111 | + } |
| 112 | +} |
0 commit comments