Office 365–Change the password expiration policy

The default password expiration policy of Office 365 is set to 90 days. That means that users have to change their password every 90 days. I think basically this is a good and secure policy but on the other side, it can be annoying and maybe your company has an other security policy or for some other reason you have to deactivate/change this.
We can change this setting through PowerShell with the Microsoft Online PowerShell Module.

 

  1. First connect to Office 365 via PowerShell more on this here. Consider, you need administration privileges to change account settings for other users..
  2. To get a list of the Microsoft Online Office 365 users:

    Get-MsolUser

    Microsoft Online Services Module for Windows PowerShell_2012-03-28_14-43-35

  3. To get the details for a user:

    Get-MsolUser -UserPrincipalName user.name@domain.xy

    Microsoft Online Services Module for Windows PowerShell_2012-03-28_14-46-19

  4. Now you can use the following cmdlet to change the password policy for the password to never expire..

    Set-MsolUser –UserPrincipalName user@contoso.com –PasswordNeverExpires $true

  5. and if you’re a freak like me Zwinkerndes Smiley

    Get-MsolUser | Set-MsolUser -PasswordNeverExpires $true

    Microsoft Online Services Module for Windows PowerShell_2012-03-28_14-55-16

    That will change the password policy for all users – have phun!

2 thoughts on “Office 365–Change the password expiration policy

  1. Thank you!!!! This is my first introduction to PowerShell for 365. I love it!

  2. If you have directory sync, you could end up with an error.. (to many transactions because of to many useraccounts).
    This command only changes it for licensed users.

    Get-MsolUser | where-object {$_.islicensed} | Set-MsolUser -PasswordNeverExpires $true

Leave a Reply

Your email address will not be published. Required fields are marked *