In Microsoft 365 environments, administrators may enforce a policy that forces users to change their password at the next login. This is a common security control used when:
When this setting is toggled, Azure AD logs an audit event called “Update PasswordProfile” under the “UserManagement” category. This event is distinct from actual password resets — it captures the enforcement of the “must change password on next login” requirement.
In this article, you'll learn how to use Graph PowerShell to query and display these security-driven admin actions in a clean and readable format.
# Connect to Microsoft Graph
Connect-MgGraph -Scopes "AuditLog.Read.All"
# Define UTC time range in strict ISO 8601 format
$startTime = (Get-Date).AddDays(-7).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ")
# Build OData filter string
$filter = "category eq 'UserManagement' and activityDisplayName eq 'Update PasswordProfile' and activityDateTime ge $startTime"
# Retrieve audit logs
$logs = Get-MgAuditLogDirectoryAudit -Filter $filter -All
# Format output
$output = foreach ($log in $logs) {
$targetUser = ($log.targetResources | Select-Object -First 1).userPrincipalName
$adminUser = $log.initiatedBy.user.userPrincipalName
[PSCustomObject]@{
"Reset Time" = $log.activityDateTime
"Reset User Account (UPN)" = $targetUser
"Reset Forced By (Admin UPN)"= $adminUser
"Result Status" = $log.result
}
}
# Display the output
if ($output) {
$output | Format-Table -AutoSize
} else {
Write-Host "No 'Update PasswordProfile' events found in the last 7 days." -ForegroundColor Yellow
}
The "Update PasswordProfile" event does not track regular password resets. Instead, it logs a specific administrative action:
When an admin enforces a password change at next sign-in by toggling the forceChangePasswordNextSignIn flag for a user.
This is commonly done for:
It's a preventive or reactive security control, not a reset log.
You can customize the script as needed:
$output | Export-Csv -Path "ForcedPasswordChangeAudit.csv" -NoTypeInformation
$output | Where-Object { $_."Reset Forced By (Admin UPN)" -like "*securityadmin@" }
(Get-Date).AddDays(-30)
Error | Cause | Solution |
Invalid filter clause | Incorrect DateTime format | Use ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ") |
Access Denied | Missing permissions | Ensure AuditLog.Read.All is granted and consented |
Parameter not found | Using unsupported params | Don’t use -ConsistencyLevel, -Property, etc. |
The Update PasswordProfile audit event offers valuable visibility into admin-triggered password change requirements, especially in environments where password hygiene and account integrity are paramount.
With the help of Graph PowerShell, you can extract these entries, review the actions taken, and build automated alerting or auditing solutions to maintain compliance and security awareness across your Microsoft 365 tenant.
© m365corner.com. All Rights Reserved. Design by HTML Codex