• Outlook User
  • New Outlook app
  • Outlook.com
  • Outlook Mac
  • Outlook & iCloud
  • Developer
  • Microsoft 365 Admin
    • Common Problems
    • Microsoft 365
    • Outlook BCM
    • Utilities & Addins

Office365: Set account passwords to never expire

Slipstick Systems

› Microsoft 365 › Office365: Set account passwords to never expire

Last reviewed on February 1, 2018     24 Comments

By default, the passwords for Office 365 accounts are set to expire after 90 days. In order to set them to never expire, the PasswordPolicies  setting needs to be changed.

You can now turn off password expiration or change the days before expiration in Office 365 via the Office 365 admin web interface.

Log into the Office 365 Admin center, expand the Settings menu, select Security & privacy. Click Edit if you need to change any of the settings.
change the password policy

If the password is set to expire, you can change the password age or the length of notification.
change the password policy in the admin console

Using PowerShell

You can use either the AzureAD or MSOnline module to check password settings.

MSOline Module

If you don't have MSOline module installed, open PowerShell using Run as Administrator and use this to install:

Install-Module MSOnline

To connect to it, use this cmdlet, entering your administrator username and password when asked.

Connect-MSOLService

To list all users and see if their password expires, use this cmdlet:

Get-MSOLUser | Select UserPrincipalName, PasswordNeverExpires

powershell-passwords-expire

Check password settings
To check the PasswordNeverExpires for just one user, use this cmdlet, replacing alias with the user's alias.

Get-MSOLUser -UserPrincipalName alias | Select PasswordNeverExpires

Set passwords to never expire
Use this cmdlet to set all user's passwords to never expire.

Get-MSOLUser  | Set-MSOLUser –PasswordNeverExpires $true

To change a single user, use the following command, replacing alias with the user's alias.

Set-MsolUser -UserPrincipalName alias -PasswordNeverExpires $true

To change the passwords to expire, run the cmdlet above but use $false instead of $true.

AzureAD Module

If you don't yet have the AzureAd cmdlets installed, open PowerShell using Run as Administrator and use this to install them:

Install-Module AzureAD

With AzureAD installed, run this cmdlet and sign in using the administrator username and password.

Connect-AzureAD

Check password settings
To see the PasswordPolicies setting for all users, run this cmdlet:

Get-AzureADUser | Select UserPrincipalName, PasswordPolicies

azureAD password policies

To check the PasswordPolicies for just one user, use this cmdlet, replacing alias with the user's alias. (You can use the users email address instead of the alias.)

Get-AzureADUser -SearchString alias | Select UserPrincipalName, PasswordPolicies

Set passwords to never expire
Use this cmdlet to set all user's passwords to never expire.

Get-AzureADUser -All $true | Set-AzureADUser -PasswordPolicies DisablePasswordExpiration

To change a single user, use the following command, replacing alias with the user's alias.

Set-AzureADUser  -SearchString alias -PasswordPolicies DisablePasswordExpiration

To get a list of users with password set to never expire:

Get-AzureADUser | ? {$_.PasswordPolicies -match "DisablePasswordExpiration"}

More Information

Set-AzureADUser
Get-AzureADUser

Office365: Set account passwords to never expire was last modified: February 1st, 2018 by Diane Poremsky
Post Views: 73

Related Posts:

  • Find Users with Send On Behalf Permission
  • Bulk Add Addresses to Safe and Blocked Senders Lists
  • Use Powershell to configure Automatic Replies
  • Office 365 Exchange: Remove-CalendarEvents

About Diane Poremsky

A Microsoft Outlook Most Valuable Professional (MVP) since 1999, Diane is the author of several books, including Outlook 2013 Absolute Beginners Book. She also created video training CDs and online training classes for Microsoft Outlook. You can find her helping people online in Outlook Forums as well as in the Microsoft Answers and TechNet forums.

Comments

  1. Curious User says

    February 2, 2023 at 3:51 pm

    silly question but If I make the changes by setting the password to never expire via MSOL, will this only affect current users but also future users?

    Reply
    • Diane Poremsky says

      February 2, 2023 at 8:23 pm

      It will affect all users, current and new.

      Reply
  2. Amol Sanjayrao Kale says

    September 29, 2022 at 5:59 am

    Thanks ma'am

    Reply
  3. Jeff says

    July 2, 2019 at 5:27 pm

    Hi, This is awesome information. I'm curious if there is a way to modify this so that a script could be run that turns on PasswordNeverExpires for individual accounts *IF* MFA is active on that account. We have some users that have bought into the MFA and have it active, but some users that do not want an MFA login. The users who have MFA active, should not need to change their primary passwords. I'm hoping to set something up that nightly checks for MFA and then sets passwordtoneverexpire *IF* MFA is active. On this site, you can query for MFA status, but I've got no idea how or if you can create something that queries MFA status and then pipes that into something that would change the passwordneverexpires status.

    Thanks
    Jeff

    Reply
  4. R Kendall says

    February 1, 2018 at 4:57 am

    The PowerShell module is no longer available :-( I get the message "Microsoft Connect Has Been Retired"

    And the new links too confusing to even find the correct download.

    Reply
    • Diane Poremsky says

      February 1, 2018 at 3:38 pm

      Without installing anything (and provided you can log into office 365 with PowerShell), what happens when you enter these two lines;
      Connect-MSOLService -Credential $LiveCred
      Get-MSOLUser | Select UserPrincipalName, PasswordNeverExpires

      It works here and I'm pretty sure I never installed the connector on this computer. (Will test it from a VM next to be sure.)

      Reply
    • Diane Poremsky says

      February 1, 2018 at 4:51 pm

      Apparently, i had the mso stuff installed as it works on my desktop but not on a different computer, even after installing the 2 files in the article footer (the first and last of the 3 still listed)
      this worked on the test system:
      You need to install the AzureAD stuff - (need to use run as admin when youy open powershell)
      Install-Module AzureAD
      then this to check the policies
      Get-azureadUser | Select UserPrincipalName, PasswordPolicies

      and this to set a policy on a user
      Set-AzureADUser -ObjectId address -PasswordPolicies DisablePasswordExpiration

      https://docs.microsoft.com/en-us/powershell/module/azuread/set-azureaduser?view=azureadps-2.0

      Reply
    • Diane Poremsky says

      February 1, 2018 at 5:29 pm

      The instructions are updated. Thanks for bringing it to my attention.

      Reply
    • Diane Poremsky says

      February 1, 2018 at 8:39 pm

      Sheesh... right after i update the page, i find a new KB article that has this:
      Install-Module MSOnline
      Connect-MsolService
      lol. with those installed the mso code works...
      Connect-MSOLService -Credential $LiveCred
      Get-MSOLUser | Select UserPrincipalName, PasswordNeverExpires
      (guess I will update the page again and add both msol and azuread methods. )

      Reply
  5. Jeremy Dick says

    November 13, 2017 at 11:22 am

    Btw if you are using the Azure AD 2.0 module then here is the updated command:
    Set-AzureADUser -ObjectId username@domain.com -PasswordPolicies DisablePasswordExpiration

    Even Microsoft's own support page on this from August 2017 is showing the old commands so go figure.

    Reply
    • Diane Poremsky says

      November 13, 2017 at 11:32 am

      plus you no longer need to use powershell at all, fortunately.

      Reply
  6. anon says

    July 24, 2017 at 5:30 am

    Hello,

    Excuse me for correcting you, but if you use $LiveCred = Get-Credential, then the Connect-MSOLService -Credential $cred would as for your credentials again, because the $cred should be $LiveCred, as in the command that defines it... ;)

    Reply
    • Diane Poremsky says

      July 26, 2017 at 12:28 am

      Heh... no one noticed that mistake until now. Thanks.

      Reply
  7. Juan says

    August 11, 2016 at 2:32 pm

    Hi Diane,

    Is there a way to set individual expiration dates, i.e., standard accounts expire after 90 days, service accounts expire after 6 months?

    Thank you in advance

    Reply
    • Diane Poremsky says

      August 14, 2016 at 10:06 pm

      In straight, simple Office 365, no. If you use a hybrid config or Azure AD, possibly - Azure AD apports a fine grained password policy, newer versions of Windows server do. I'm not sure if the basic Azure AD supports the policy or if you need the premium AD offering.

      Reply
  8. me says

    January 12, 2016 at 5:16 pm

    EVERY page I find online has these steps. EVERY time I run "Connect-MSOLService -Credential $cred" I get: The term 'Connect-MSOLService' is not recognized as the name of a cmdlet, function, script file, or operable program

    Why does no one explain this!?

    Reply
    • Diane Poremsky says

      January 13, 2016 at 1:20 am

      Do you have the Online Services Assistant installed? That is needed - you might also need the Online Services Module for Windows PowerShell installed.

      Reply
    • Jeremy Dick says

      November 13, 2017 at 11:09 am

      Yeah I'm having the same issue and I encounter this a lot when looking for Azure PowerShell commands. Issue is that there is the much more documented older set of commands (you can tell right way if "Msol" is in them) based on the older Azure AD module (installed using "Install-Module -Name MSOnline"). And then the much less documented newer set of commands based on the newer Azure AD 2.0 module (installed using "Install-Module -Name AzureAD"). Which is then also reliant upon using PowerShell 3.0 or above.

      For example the instructions change right off the bat. You connect to Azure AD using "Connect-AzureAD" instead of "Connect-MSOLService". I don't think you see Msol in any of the newer commands.

      The newer module is supposed to support more features but its all rather useless if you can never find the commands you need. The "newer" module is over a year old now but you can see here articles written as recently as July are still referencing the older module. That is MS always keeping things interesting for you.

      So you'll probably have to end up digging through Microsoft's own documentation to find the commands you need or revert to the older module:
      https://docs.microsoft.com/en-us/powershell/module/azuread/?view=azureadps-2.0

      Reply
  9. KM in NYC says

    May 6, 2015 at 3:39 pm

    Thanks for sharing this, Diane! Was very helpful to figure out who got missed when we initially set them up.

    Just an update here as I stumbled across this post from 2013 in May of 2015: it appears that you *can* now set "Passwords to never expire" in the Office 365 Admin portal as follows:

    Office 365 Admin Center > Service Settings > Passwords > "Passwords never expire" (checkbox)

    There are also settings for "Days before passwords expire" and "Days before a user is notified that their password will expire" which become grayed out when checking the "...never expire" box.

    Reply
  10. Mo says

    February 17, 2015 at 8:21 am

    Thank you so much Diane for the easy to follow and precise instruction :-)

    Reply
  11. Luis says

    June 16, 2014 at 10:12 am

    Thank you!!!

    Reply
  12. Erik Christensen says

    June 13, 2014 at 2:56 am

    Thank you very much! Just what I needed.

    Reply
  13. Webentwicklung says

    December 5, 2013 at 5:15 am

    This finally worked for me thank you.

    Is it possible to set this flag / cmdlet for all future created users?

    or will I have to redo it whenever I create a new user?

    Reply
    • Diane Poremsky says

      December 5, 2013 at 9:04 am

      You'll need to do each user as you add them. You can set the expiration date globally, in the Office 365 portal (or using a cmdlet), to up to 720 days. That way it's not so annoying and you can run it on all accounts once a year (or just let them expire every 2 years)

      Reply

Leave a Reply Cancel reply

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

Visit Slipstick Forums.
What's New at Slipstick.com

Latest EMO: Vol. 31 Issue 7

Subscribe to Exchange Messaging Outlook






Support Services

Do you need help setting up Outlook, moving your email to a new computer, migrating or configuring Office 365, or just need some one-on-one assistance?

Our Sponsors

CompanionLink
ReliefJet
  • Popular
  • Latest
  • Week Month All
  • Use Classic Outlook, not New Outlook
  • How to Remove the Primary Account from Outlook
  • Reset the New Outlook Profile
  • Disable "Always ask before opening" Dialog
  • How to Hide or Delete Outlook's Default Folders
  • This operation has been cancelled due to restrictions
  • Change Outlook's Programmatic Access Options
  • Use Public Folders In new Outlook
  • Adjusting Outlook's Zoom Setting in Email
  • Removing Suggested Accounts in New Outlook
  • Sync Issues and Errors with Gmail and Yahoo accounts
  • Error Opening iCloud Appointments in Classic Outlook
  • Opt out of Microsoft 365 Companion Apps
  • Mail Templates in Outlook for Windows (and Web)
  • Urban legend: Microsoft Deletes Old Outlook.com Messages
  • Buttons in the New Message Notifications
  • Move Deleted Items to Another Folder Automatically
  • Open Outlook Templates using PowerShell
  • Count and List Folders in Classic Outlook
  • Google Workspace and Outlook with POP Mail
Ajax spinner

Recent Bugs List

Microsoft keeps a running list of issues affecting recently released updates at Fixes or workarounds for recent issues in classic Outlook (Windows).

For new Outlook for Windows: Fixes or workarounds for recent issues in new Outlook for Windows .

Outlook for Mac Recent issues: Fixes or workarounds for recent issues in Outlook for Mac

Outlook.com Recent issues: Fixes or workarounds for recent issues on Outlook.com

Office Update History

Update history for supported Office versions is at Update history for Office

Outlook Suggestions and Feedback

Outlook Feedback covers Outlook as an email client, including Outlook Android, iOS, Mac, and Windows clients, as well as the browser extension (PWA) and Outlook on the web.

Outlook (new) Feedback. Use this for feedback and suggestions for Outlook (new).

Use Outlook.com Feedback for suggestions or feedback about Outlook.com accounts.

Other Microsoft 365 applications and services




New Outlook Articles

Sync Issues and Errors with Gmail and Yahoo accounts

Error Opening iCloud Appointments in Classic Outlook

Opt out of Microsoft 365 Companion Apps

Mail Templates in Outlook for Windows (and Web)

Urban legend: Microsoft Deletes Old Outlook.com Messages

Buttons in the New Message Notifications

Move Deleted Items to Another Folder Automatically

Open Outlook Templates using PowerShell

Count and List Folders in Classic Outlook

Google Workspace and Outlook with POP Mail

Newest Code Samples

Open Outlook Templates using PowerShell

Count and List Folders in Classic Outlook

Insert Word Document into Email using VBA

Warn Before Deleting a Contact

Use PowerShell to Delete Attachments

Remove RE:, FWD:, and Other Prefixes from Subject Line

Change the Mailing Address Using PowerShell

Categorize @Mentioned Messages

Send an Email When You Open Outlook

Delete Old Calendar Events using VBA

Repair PST

Convert an OST to PST

Repair damaged PST file

Repair large PST File

Remove password from PST

Merge Two Data Files

Sync & Share Outlook Data

  • Share Calendar & Contacts
  • Synchronize two computers
  • Sync Calendar and Contacts Using Outlook.com
  • Sync Outlook & Android Devices
  • Sync Google Calendar with Outlook
  • Access Folders in Other Users Mailboxes

Diane Poremsky [Outlook MVP]

Make a donation

Mail Tools

Sending and Retrieval Tools

Mass Mail Tools

Compose Tools

Duplicate Remover Tools

Mail Tools for Outlook

Online Services

Calendar Tools

Schedule Management

Calendar Printing Tools

Calendar Reminder Tools

Calendar Dates & Data

Time and Billing Tools

Meeting Productivity Tools

Duplicate Remover Tools

Productivity

Productivity Tools

Automatic Message Processing Tools

Special Function Automatic Processing Tools

Housekeeping and Message Management

Task Tools

Project and Business Management Tools

Choosing the Folder to Save a Sent Message In

Run Rules on messages after reading

Help & Suggestions

Submit Outlook Feature Requests

Slipstick Support Services

Buy Microsoft 365 Office Software and Services

Visit Slipstick Forums.

What's New at Slipstick.com

Home | Outlook User | Exchange Administrator | Office 365 | Outlook.com | Outlook Developer
Outlook for Mac | Common Problems | Utilities & Addins | Tutorials
Outlook & iCloud Issues | Outlook Apps
EMO Archives | About Slipstick | Slipstick Forums
Submit New or Updated Outlook and Exchange Server Utilities

Send comments using our Feedback page
Copyright © 2026 Slipstick Systems. All rights reserved.
Slipstick Systems is not affiliated with Microsoft Corporation.