An edited version of this article appeared on the Netwrix blog on May 25, 2017. Credit: Netwrix
One of the most frequently asked questions we come across here is users or administrators who subscribe to Office 365 but who tire of being prompted to change their passwords when they expire. These users might not be used to Microsoft’s default password expiration policy for the service, especially if they are coming from an in house system that had a more lenient expiration requirement. While I am not entirely convinced setting passwords to never expire is a smart move, if you choose secure passwords and use multifactor authentication, I do not think you are opening up a big can of worms by disabling expiry.
Configuring Using PowerShell
As always, here is a good old PowerShell coming in for the rescue. First off, you need to set yourself up to connect to the service through PowerShell remoting. If you have not done this yet, then you will need two pieces of software: the Microsoft Online Services Sign-In Assistant for IT Professionals RTW (yes, that’s the official name), and the Azure Active Directory Module for Windows PowerShell. Install both of those, then open up a PowerShell command session and type in
And then enter your credentials at the prompt.
Once you have successfully authenticated, then enter the following command to set one particular user’s password to never expire:
Set-MsolUser -UserPrincipalName <firstname.lastname@example.org> -PasswordNeverExpires $true
If you know a little bit about PowerShell, then you also know that if the verb in a command is Set, then you can also use Get to get information or properties about a certain object. In this case, we can use Get-MsolUser to see if the user’s password has already been configured to never expire, and we do so using the following command which selects that one certain attribute among many to display as a response to our command:
Get-MsolUser -UserPrincipalName <email@example.com> | Select PasswordNeverExpires
You can extrapolate this command to see the password expiration status of all users in your tenant by using the following command:
Get-MSOLUser | Select UserPrincipalName, PasswordNeverExpires
You can also combine these two commands to set all of the users in your tenant to have passwords that never expire using the pipelining feature of PowerShell. Here we get a list of users from Get-MsolUser and then we pipe that information to Set-MsolUser, leaving out the specific reference to names since those will be fed into the new command from the pipeline, and we can leave the attribute configuration the same:
Get-MsolUser | Set-MsolUser –PasswordNeverExpires $true
Configuring using the Graphical User Interface (GUI)
If you’re afraid of the PowerShell command line, two words of advice: 1) do not fear it, for it is your friend, and 2) there is also a way to take care of this from within the web based Office 365 administration console. You will need to have administrator credentials for this.
- Sign in at https://portal.office.com/adminportal/home.
- From the Settings menu, select Security and privacy, and then click Edit.
- Under Password policy, click to On the lever that says “Set user passwords to never expire.”