Office 365 – Set Password Never Expire

Command:

Get-MSOLUser -UserPrincipalName | Select PasswordNeverExpires

Additional, to check if the users “Password never expires setting” are set true, you can run the following PowerShell command:
Command:

Get-MSOLUser -UserPrincipalName [email protected] | FL

Alternatively, to see all users and their “Password never expires setting”, you can run the following PowerShell command:
Command:

Get-MSOLUser | Select UserPrincipalName, PasswordNeverExpires

How to enable the “Password never expires” setting
1. Connect to the Microsoft Online Services Module for Windows PowerShell by using your company administrator credentials.
2. Run the following command by using the user principal name (UPN) or the Microsoft Online Services ID of the user to configure the password for that user to never change:
Command:

Set-MsolUser -UserPrincipalName [email protected] -PasswordNeverExpires $true

Note If you want to change the setting for all the users in an organization, run the following command:
Command:

Get-MSOLUser | Set-MsolUser -PasswordNeverExpires $true

How to disable the “Password never expires” setting
1. Connect to the Microsoft Online Services Module for Windows PowerShell (MOSMWP) by using your company administrator credentials.
2. Run the following command by using the user principal name (UPN) or the Microsoft Online Services ID of the user to disable the Password never expire setting for that user:
Command:

Set-MsolUser -UserPrincipalName -PasswordNeverExpires $false

Note If you want to change the setting for all the users in an organization, use the following cmdlet:
Command:

Get-MSOLUser | Set-MsolUser -PasswordNeverExpires $false

For users who are synchronized through directory synchronization
The PasswordNeverExpires setting for synchronized users must be configured by using the steps earlier in this article.
There is no Active Directory property that can be synchronized to Office 365 to set the PasswordNeverExpires setting.