When you create a user in Office 365, it comes with a standard expiration policy for the passwords. Typically this is 3 months.

Although this is a standard and best practice, sometimes you may want to have a user who’s password never expires. Typical example is the users created for integrating services (i.e. which act as a service account). The argument could be that there is an overhead on maintenance, plus could impact the integrating services if a password expires.

 

Before you begin

You will need couple of things before you can execute the commands / scripts mentioned below. You can refer to my earlier blogs…

 

Find out whether Password is set to ‘Never Expire’

Once you have successfully established connection with O365; for an individual user you can use Get-MsolUser cmdlet to determine this.

$SelectedUser = Get-MsolUser -UserPrincipalName <<User Principal ID>>

$SelectedUser.PasswordNeverExpires

OR

Get-MsolUser -UserPrincipalName <<User Principal ID>> | Select PasswordNeverExpires

For multiple users you can write a little script to read the users from a CSV file and display the results…

 

Set Password to ‘Never Expire’

For this you need to use Set-MsolUser cmdlet.

Set-MsolUser -UserPrincipalName <<User Principal ID>> -PasswordNeverExpires $true

Leave a comment