This article will show you how to configure a user password to never expire on the Office 365 platform.
Install the PowerShell cmdlets for Office 365
First you will need the PowerShell cmdlets installed onto your computer. To install them, please follow the instructions here:
Set Windows Powershell Credentials
To connect Windows Powershell to Office 365, run the following cmdlet from the Powershell window (which you installed in the above step).
After running that command, you will get a login window. Type in an "admin" level user for Office 365 (in the format of firstname.lastname@example.org) and select "Ok".
Connect Windows Powershell to Office 365
Next, run the following cmdlet:
connect-MSOLService -credential $cred
If it connects successfully, no messages will be should be shown, just a new line as shown in the above screenshot.
If You Get an Error . . .
If the credentials you've provided are incorrect, you will get a screen like the one above. If this happens, check your credentials and re-run the cmdlets above.
Find Out Whether a Password is Set to Never Expire
To see whether a single user’s password is set to never expire, run the following cmdlet by using the user ID (in the format of email@example.com) of the user you want to check:
Get-MSOLUser -UserPrincipalName <user ID> | Select PasswordNeverExpires
The result of the cmdlet will show if this flag has been set or not for this user. An example of this can be seen in the above screenshot. For this particular user, it has not been set.
Optional -- To see the "Password never expires" setting for all users, run the following cmdlet:
Get-MSOLUser | Select UserPrincipalName, PasswordNeverExpires
Set a Password to Never Expire
To set the password of one user to never expire, run the following cmdlet by using the user ID of the user (in the format of firstname.lastname@example.org):
Set-MsolUser -UserPrincipalName <user ID> -PasswordNeverExpires $true
Optional -- To set the passwords of all the users in an organization to never expire, run the following cmdlet:
Get-MSOLUser | Set-MsolUser -PasswordNeverExpires $true
Set a Password to Expire (To Undo Above)
To set the password of one user so that the password does expire, run the following cmdlet by using the user ID of the user:
Set-MsolUser -UserPrincipalName <user ID> -PasswordNeverExpires $false
To set the passwords of all users in the organization so that they do expire, use the following cmdlet:
Get-MSOLUser | Set-MsolUser -PasswordNeverExpires $false