How to Bulk Reset Unique Microsoft 365 Passwords with PowerShell
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.

- 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.
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.
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.
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.
Open PowerShell as an Administrator and run 'Connect-MgGraph -Scopes "User.ReadWrite.All"' to authenticate with your Microsoft 365 tenant.
Run the command '$users = Import-Csv -Path "C:\path\to\users.csv"' to load the data into a variable.
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 the Legacy MSOnline Module
Use this method if your organization's environment still relies on legacy MSOnline scripts, though upgrading to Graph is highly recommended.
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.

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.




