Self-Service Password Reset (SSPR) allows users to reset their passwords without IT intervention, improving productivity while maintaining security. As an administrator, it's essential to monitor SSPR activity to ensure it's being used effectively and securely.
In this article, we walk through a Graph PowerShell script that retrieves all self-service password reset events and provides a detailed report, including reset time, user account, and status (success or failure).
# Connect to Microsoft Graph with appropriate permission
Connect-MgGraph -Scopes "AuditLog.Read.All"
# Retrieve directory audit logs for self-service password resets
$SSPRLogs = Get-MgAuditLogDirectoryAudit -Filter "category eq 'UserManagement' and activityDisplayName eq 'Reset password (self-service)'" -All
# Display relevant headers in PowerShell console
$SSPRLogs | Select-Object `
@{Name = "Reset Time"; Expression = { $_.ActivityDateTime }},
@{Name = "Reset User Account"; Expression = { $_.TargetResources[0].UserPrincipalName }},
@{Name = "Result Status"; Expression = {
if ($_.Result -eq "success") { "Success" }
else { "Failure" }
}} |
Format-Table -AutoSize
Here are some ways to make the script more powerful and tailored:
To only see events from the past 30 days:
$Since = (Get-Date).AddDays(-30)
$RecentSSPRLogs = $SSPRLogs | Where-Object { $_.ActivityDateTime -ge $Since }
Useful for sharing reports or compliance records:
$SSPRLogs | Select-Object ... | Export-Csv -Path ".\SSPR_Report.csv" -NoTypeInformation
To analyze success rates:
$SSPRLogs | Group-Object Result | Select Name, Count
| Error | Cause | Solution |
| Connect-MgGraph is not recognized | Microsoft Graph module not installed | Run Install-Module Microsoft.Graph -Scope CurrentUser |
| Insufficient privileges to call this API | Missing or unconsented Graph permissions | Ensure AuditLog.Read.All is granted and admin consent is given |
| TargetResources[0] is null | Some events may not include UPN data | Add null checks or skip such entries with Where-Object filters |
This Graph PowerShell script is a straightforward yet effective way to monitor password reset (self-service) events in your Microsoft 365 tenant. It helps administrators stay informed about user-initiated password resets and adds another layer to your organization’s auditing and security posture. With minor tweaks, it can be adapted for scheduled reporting or dashboard integration.
© m365corner.com. All Rights Reserved. Design by HTML Codex