The default Expiration of user passwords is set to 90 days, here are commands to configure passwords to never expire for Office 365
- Please download Microsoft Online Services Module for Powershell
- Open Office 365 Powershell Module as an administrator
- To connect run:
Connect-MSOLservice
(Enter administrator credentials)
Set password never expire for one user
Set-MsolUser -UserPrincipalName user@example.com -PasswordNeverExpires $true
Set password never expire for all user
Get-MSOLUser | set-msoluser -PasswordNeverExpires $true
Check what users have the password never expire
Get-MSOLUser | select user*, password*
Alternatively, to see all users and their "Password never expires setting", you can run the following PowerShell command:
Get-MSOLUser | Select UserPrincipalName, PasswordNeverExpires
To check if one user has enabled, run the command below:
Get-MSOLUser -UserPrincipalName user@domain.com | select user*, password*
Note
This procedure does not apply to users who are enabled for single
sign-on (SSO). This is because passwords for SSO-enabled users are
managed in the on-premises environment. If you try to perform this
procedure for an SSO-enabled user, you receive output that resembles the
following in Windows PowerShell:
Set-MsolUser : Unable to update parameter. Parameter name: PasswordPolicies.
At line:1 char:13
+ Set-MsolUser <<<< -UserPrincipalName jsmith@contoso.com
-PasswordNeverExpires $true
+ CategoryInfo : OperationStopped: ( : ) [Set-MsolUser], MicrosoftOnlineException
+ FullyQualifiedErrorId : Microsoft.Online.Administration.Automation.PropertyNotSettableException, Microsoft.Online.Administration.Automation.SetUser
Note Only passwords for user accounts that are not synchronized through directory synchronization can be configured to never expire.