• 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

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.

Subscribe
Notify of
24 Comments
newest
oldest most voted
Inline Feedbacks
View all comments

Curious User
February 2, 2023 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?

0
0
Reply
Diane Poremsky
Author
Reply to  Curious User
February 2, 2023 8:23 pm

It will affect all users, current and new.

0
0
Reply
Amol Sanjayrao Kale
September 29, 2022 5:59 am

Thanks ma'am

0
0
Reply
Jeff
July 2, 2019 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

0
0
Reply
R Kendall
February 1, 2018 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.

0
0
Reply
Diane Poremsky
Author
Reply to  R Kendall
February 1, 2018 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.)

0
0
Reply
Diane Poremsky
Author
Reply to  R Kendall
February 1, 2018 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

1
0
Reply
Diane Poremsky
Author
Reply to  R Kendall
February 1, 2018 5:29 pm

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

0
0
Reply
Diane Poremsky
Author
Reply to  R Kendall
February 1, 2018 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. )

0
0
Reply
Jeremy Dick
November 13, 2017 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.

0
0
Reply
Diane Poremsky
Author
Reply to  Jeremy Dick
November 13, 2017 11:32 am

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

0
0
Reply
anon
July 24, 2017 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... ;)

0
0
Reply
Diane Poremsky
Author
Reply to  anon
July 26, 2017 12:28 am

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

0
0
Reply
Juan
August 11, 2016 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

0
0
Reply
Diane Poremsky
Author
Reply to  Juan
August 14, 2016 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.

0
0
Reply
me
January 12, 2016 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!?

0
0
Reply
Diane Poremsky
Author
Reply to  me
January 13, 2016 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.

0
0
Reply
Jeremy Dick
Reply to  me
November 13, 2017 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:… Read more »

0
0
Reply

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

Latest EMO: Vol. 30 Issue 34

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
  • Mail Templates in Outlook for Windows (and Web)
  • How to Remove the Primary Account from Outlook
  • Reset the New Outlook Profile
  • Disable "Always ask before opening" Dialog
  • Adjusting Outlook's Zoom Setting in Email
  • This operation has been cancelled due to restrictions
  • How to Hide or Delete Outlook's Default Folders
  • Change Outlook's Programmatic Access Options
  • Shared Mailboxes and the Default 'Send From' Account
  • 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
  • Import EML Files into New Outlook
  • Opening PST files in New Outlook
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

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

Import EML Files into New Outlook

Opening PST files in New Outlook

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 © 2025 Slipstick Systems. All rights reserved.
Slipstick Systems is not affiliated with Microsoft Corporation.

:wpds_smile::wpds_grin::wpds_wink::wpds_mrgreen::wpds_neutral::wpds_twisted::wpds_arrow::wpds_shock::wpds_unamused::wpds_cool::wpds_evil::wpds_oops::wpds_razz::wpds_roll::wpds_cry::wpds_eek::wpds_lol::wpds_mad::wpds_sad::wpds_exclamation::wpds_question::wpds_idea::wpds_hmm::wpds_beg::wpds_whew::wpds_chuckle::wpds_silly::wpds_envy::wpds_shutmouth:
wpDiscuz

Sign up for Exchange Messaging Outlook

Our weekly Outlook & Exchange newsletter (bi-weekly during the summer)






Please note: If you subscribed to Exchange Messaging Outlook before August 2019, please re-subscribe.

Never see this message again.

You are going to send email to

Move Comment