Password & Account Recovery

How to Bulk Reset Unique Microsoft 365 Passwords with PowerShell

Emma BrownEmma Brown Nov 2, 2026 870 views

Question details

An administrator needs to assign unique, permanent passwords to existing Microsoft 365 users in bulk using a CSV file and PowerShell, as manual individual updates are too time-consuming.

Bulk Reset Unique Permanent Microsoft 365 User Passwords with PowerShell
Product
Microsoft 365
Device & OS
not provided
Scenario
Administering bulk account credentials where each user requires a specific new permanent password imported from a CSV file.
Observed behavior
Previous attempts to import the CSV and apply passwords using Get-MsolUser and Set-MsolUserPassword failed to update the accounts as intended.
Before you start

Ensure you have global administrator or privileged authentication administrator rights in your Microsoft 365 tenant, and verify that your CSV file is formatted correctly with the exact headers referenced in your script.

Solution 1Recommended

Bulk Reset Passwords Using Microsoft Graph PowerShell

Microsoft Graph is the recommended, modern method for managing Microsoft 365 accounts, replacing the deprecated MSOnline module.

Since Microsoft is deprecating older modules, Microsoft Graph PowerShell SDK is the most secure and reliable way to update user credentials. You will need to prepare a CSV file with two columns: UserPrincipalName and NewPassword.

1
Prepare your CSV file

Create a CSV file named 'users.csv'. Add two column headers: 'UserPrincipalName' and 'NewPassword'. Populate the rows with the users' email addresses and their respective unique new passwords, then save the file.

2
Connect to Microsoft Graph

Open PowerShell as an Administrator and run 'Connect-MgGraph -Scopes "User.ReadWrite.All"' to authenticate with your Microsoft 365 tenant.

3
Import the CSV and loop through users

Run the command '$users = Import-Csv -Path "C:\path\to\users.csv"' to load the data into a variable.

4
Execute the password update script

Use a foreach loop to iterate through the list: 'foreach ($user in $users) { $PasswordProfile = @{ Password = $user.NewPassword; ForceChangePasswordNextSignIn = $false }; Update-MgUser -UserId $user.UserPrincipalName -PasswordProfile $PasswordProfile }'. This sets a permanent password for each user.

Bulk Reset Passwords Using Microsoft Graph PowerShell
Security Tip: Always test your script on a small batch of 2-3 test users before running it against your entire organization to prevent accidental lockouts.
Free Microsoft Office alternative

Streamline Your Office Tasks with WPS Office

While you manage complex IT administration and Microsoft 365 user credentials via PowerShell, you can provide your users with a highly compatible, easy-to-deploy productivity suite. WPS Office is a lightweight and robust alternative to Microsoft Office that saves on licensing costs.

Free and lightweight alternative to Microsoft OfficeFully compatible with Microsoft Word, Excel, and PowerPoint formats (.docx, .xlsx, .pptx)Familiar tabbed user interface requires zero training for seamless migrationBuilt-in PDF editing tools for comprehensive document workflows
microsoft office alternative - wps office

Frequently Asked Questions

Why did my previous script using Set-MsolUserPassword fail to update the passwords?

This commonly occurs if the CSV headers do not perfectly match the variables called in the foreach loop (e.g., calling $_.Password instead of $_.NewPassword). It can also fail if the executing account lacks User Administrator or Global Administrator privileges.

How do I force users to change their password upon their next login instead?

If you want users to set their own permanent password, change the parameter. In MSOnline, use '-ForceChangePassword $true'. In Microsoft Graph, set 'ForceChangePasswordNextSignIn = $true' in the PasswordProfile array.

Is the MSOnline PowerShell module still supported by Microsoft?

Microsoft is actively deprecating the MSOnline and AzureAD modules. Administrators are strongly advised to migrate all user management and password reset scripts to the Microsoft Graph PowerShell SDK.

Can I output the results of the password reset to a log file?

Yes. Inside your PowerShell foreach loop, you can use a Try-Catch block and append a success or error message to a text file using 'Out-File -Append' or 'Add-Content' to track which accounts were successfully updated.