As admin of an Office 365 for business organization, you can reset
passwords for users who’ve forgotten their passwords. As we all aware
that admins can reset the password for Office 365 users from the Office
365 Admin portal, but they will not be able to set custom password for
users, instead a random password will be generated. In this blog, we see
about the different methods for setting custom password for Office 365
users.
How to set Custom Password for Single Office 365 User
Following PowerShell command is used to set Custom Password for Single
Office 365 User,
Steps involved:
- Reset the password for Office 365 user using “Set-MsolUserPassword”
cmdlet.
Set-MsolUserPassword –UserPrincipalName –NewPassword
-ForceChangePassword $False
NOTE: To force the Office 365 user to change their password the next
time they sign in, modify the “ForceChangePassword” parameter to
“$true”.
How to set Custom Password for all Office 365 Users
Following PowerShell script is used to set Custom Password for all
Office 365 Users,
Steps involved:
- Get all Office 365 users using “Get-MsolUser” cmdlet.
- Reset the password for Office 365 user using “Set-MsolUserPassword”
cmdlet.
$Users = Get-MsolUser $Users | Foreach-Object{ $User = $_
Set-MsolUserPassword -userPrincipalName $User.UserPrincipalName
–NewPassword -ForceChangePassword $False }
How to set Custom Password for Group Members
Following PowerShell script is used to set Custom Password for Office
365 Group Members,
Steps involved:
- Get all groups (Security or Distribution) using “Get-MsolGroup”
cmdlet. - Get all members of selected group using “Get-MsolGroupMember”
cmdlet. - Reset the password for Office 365 user using “Set-MsolUserPassword”
cmdlet.
$GroupName =”GroupName” $Group = Get-MsolGroup
|Where-Object{$_.DisplayName -like $GroupName} $members =
Get-MsolGroupMember -GroupObjectId $Group.ObjectId $members |
Foreach-Object{ $member = $_ Set-MsolUserPassword -ObjectId
$member.ObjectId –NewPassword -ForceChangePassword $False }
How to set Custom Password for Bulk Office 365 users using CSV file
Following PowerShell script is used to set Custom Password for Bulk
Office 365 users using CSV file,
Steps involved:
- Import the userPrincipalName of Office 365 users from CSV file using
“Import-Csv” cmdlet. - Reset the password for Office 365 user using “Set-MsolUserPassword”
cmdlet.
$csv = Import-Csv C:Users.csv Foreach ($line in $csv) {
Set-MsolUserPassword -userPrincipalName $line.UserPrincipalName
-NewPassword -ForceChangePassword $False }
Sample CSV File









