Articles on: Scripts

Bulk Password Reset of office 365 users

Description:



This script is used to reset password of office 365 users using powershell and CSV file.

In the CSV you need to create the following columns:

-UserprincipalName: Email of the user whose password you want to reset

-NewPassword: New password you want to set for the user

-ForceChangePassword: User force to change password on first login

Script 1:



Import-Csv -Path "C:\Users\Awais\Desktop\Drivers.csv" | foreach {

$users = get-msoluser | select userprincipalname,objectid | where {-userprincipalname -like $_.UserPrincipalName }

Set-MsolUserPassword -userPrincipalName $_.UserPrincipalName -NewPassword $_.Password -ForceChangePassword $False }

Script 2:



Import-Csv "C:\Users\Awais\Desktop\APSCBWP Users.csv" | % { Set-MsolUserPassword -userPrincipalName $_.UserPrincipalName -NewPassword $_.Password -ForceChangePassword $True }

Updated on: 31/01/2023

Was this article helpful?

Share your feedback

Cancel

Thank you!