# Connect to Microsoft Graph PowerShell module
# Connect-MgGraph -Scopes "User.ReadWrite.All"
# Path to your CSV file
$csvPath = "C:\temp\changepass.csv" # Replace with the actual path
# Import the CSV and process each row
Import-Csv -Path $csvPath | ForEach-Object {
$upn = $_.UserPrincipalName
$newPassword = $_.NewPassword
$forceChange = $_.ForceChangePassword
# Set the password for the user
Set-MgUserPassword -UserId $upn -PasswordProfile (New-Object -TypeName Microsoft.Open.MSGraph.Model.PasswordProfile -ArgumentList @($newPassword, $forceChange))
Write-Host "Password updated for user: $upn"
}
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article