How to set User Passwords to never expire in Office 365

image

There can be a good reason for setting certain user accounts to never expire their password. With Office 365, it is also possible to set this for a selected user account or all user accounts within the organization. Still, it is advisable not to set never expire for all accounts.

In this blog post I will describe how easy it is to set an user account in Office 365 to never expire it’s password using PowerShell.

1. Connect to your Office 365 tenant using PowerShell and the Microsoft Online Services Module

2. Set password to never expire for one user or all users

3. Validate the settings

Connect to the Office 365 tenant using PowerShell

Install the Microsoft Online Services Module and Online Sign-In Assistant from: Install the Office 365 cmdlets. When the two programs are installed, connect to Office 365 using the following command:

Connect-MSOnline

Enter your Office 365 tenant administrator credentials and your are connected.

Set password to never expire for one user

Use the following PowerShell command to set a password to never expire for one user:

Set-MSOLUser -UserPrincipalName user@user.com -PasswordNeverExpires $true

Note: If you want to reverse the changes, follow the same commands, but replace $true with $false.

Set password to never expire for all users

Use the following PowerShell command to set a password to never expire for all users in the organization:

Get-MSOLUser | Set-MsolUser -PasswordNeverExpires $true

 

The above is not recommended for security reasons, but there could be a reason to do so, that is why the command is listed.

Note: If you want to reverse the changes, follow the same commands, but replace $true with $false.

Validate the settings

Run the following commands to validate the current settings of oneuser:

Get-Msoluser -UserPrincipalName user@user.com | fl DisplayName, PasswordNeverExpires

Run the following commands to validate the current settings of all users:

Get-Msoluser | fl DisplayName, PasswordNeverExpires

Reference:

1 thought on “How to set User Passwords to never expire in Office 365”

Comments are closed.