How to set Custom Password for Office 365 User?

 Office 365, Perumal
Dec 10 2015

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:
1. Reset the password for Office 365 user using “Set-MsolUserPassword” cmdlet.

Set-MsolUserPassword –UserPrincipalName <UserPrincipalName> –NewPassword <New Password> -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:
1. Get all Office 365 users using “Get-MsolUser” cmdlet.
2. Reset the password for Office 365 user using “Set-MsolUserPassword” cmdlet.

$Users = Get-MsolUser $Users | Foreach-Object{ $User = $_ Set-MsolUserPassword -userPrincipalName $User.UserPrincipalName –NewPassword <password> -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:
1. Get all groups (Security or Distribution) using “Get-MsolGroup” cmdlet.
2. Get all members of selected group using “Get-MsolGroupMember” cmdlet.
3. 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 <password> -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:
1. Import the userPrincipalName of Office 365 users from CSV file using “Import-Csv” cmdlet.
2. 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 <password> -ForceChangePassword $False }
Sample CSV File