Office 365 / Azure Active Directory Password Management

Office 365 poses some unique challenges for some of the simplest tasks. For instance, if you want to reset a user’s password using the Web UI you’ll find you cannot simply choose the new password without forcing the user to change it upon next login. Now I admit you can make a case for this being a good for security but there exists a handful of scenarios where this can become annoying.


Fortunately, using PowerShell you can easily set a new password for a user and tell Office 365 (or to be more precise, the Azure Active Directory controller that office 365 relies upon) not to force the user to change their password upon next login.


First we’ll need to connect PowerShell to your Office 365 tenant. If you are looking for a good guide on how to do this might I suggest this great guide to Connecting PowerShell to Office 365


Once you’re connected, simply substitute your desired username and password in for the bolded examples in the script below. I would get in the habit of always putting quotes around your passwords so that PowerShell does not try to parse any special characters your password may have.

Set-MsolUserPassword -UserPrincipalName nate@get-msol.com -NewPassword Password1 -ForceChangePassword -$false

And there you have it! Powershell will spit out your password back you to confirm the command was successful.

A Two-For!

Suppose you’re reading this post because your password expired and you want to change it back to what it was originally AND prevent it form expiring again; The following command will tell Office 365 to disable password expiration for the specified user. Be sure to substitute your desired username for the bolded example.

Set-MsolUser -UserPrincipalName nate@get-msol.com -PasswordNeverExpires $true

Lastly, if you’re looking to disable password expiration for all user then this little one-liner will do the trick

Get-MsolUser | Set-MsolUser -UserPrincipalName $_.UserPrincipalName -PasswordNeverExpires $true

Just be sure to keep in mind that as you add new user’s you’ll need to re-run this command as it only modifies existing users.

As always, if you have any questions or want clarification on something in this post please feel free to contact me using the form below.

#office365 #o365 #azureactivedirectory #aad #powershell #ps101

Featured Posts
Recent Posts
Search By Tags
No tags yet.
Connect