Using Microsoft Graph to Set Users in Azure AD to force change their Password Next Login

# Import the Microsoft Graph module
Import-Module Microsoft.Graph

# Connect to Microsoft Graph with the necessary permissions (User.ReadWrite.All or Directory.AccessAsUser.All)
Connect-MgGraph -Scopes "User.ReadWrite.All"

# Specify the user's UPN (User Principal Name)
$userUPN = "[email protected]"

# Retrieve the user ID for the UPN
$user = Get-MgUser -UserId $userUPN

# Force the user to change their password at next sign-in by updating the PasswordProfile
Update-MgUser -UserId $user.Id -PasswordProfile @{ ForceChangePasswordNextSignIn = $true }

Write-Output "Password change enforced for $userUPN"
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...