Set an individual user's password to never expire

Contributors: Diane Faigel
Last updated 4 August, 2017

I forgot the username or password for the account I use with Office.

This article is for people who set password expiration policy for a business, school, or nonprofit.

If you're a user, you don't have the permissions to set your password to never expire. Ask your work or school technical support to do the steps in this article for you.

If you have company requirements to set some individual user passwords to never expire, you need to use Windows PowerShell. You can't do this in the Office 365 admin center.

If you're new to Windows PowerShell, you can do this! The PowerShell commands used in this article will only change a person's password expiration.

Your browser does not support video. Install Microsoft Silverlight, Adobe Flash Player, or Internet Explorer 9.
Video on how to set up user passwords to never expire

Important: You can only do these steps on user accounts that aren’t synchronized through directory synchronization.

Install the required PowerShell modules

  1. Install the 64-bit version of the Microsoft Online Services Sign-in Assistant: Microsoft Online Services Sign-in Assistant for IT Professionals RTW.

  2. Install the 64-bit version of the Windows Azure Active Directory Module for Windows PowerShell with these steps:

    • Open the Azure Active Directory Connection web page.

    • In Files in Download at the bottom of the page, click Download for the AdministrationConfig-V1.1.166.0-GA.msi file, and then install it.

  3. Open Windows PowerShell as an administrator:

    1. In your search bar, type Windows PowerShell.

    2. Right-click on Windows PowerShell and select Run as Administrator.

      Open PowerShell as "Run as administrator."

    3. The Windows PowerShell window will pop open. The prompt C:\Windows\system32 means you opened it as an administrator.

      What PowerShell looks like when you first open it.

    4. As a best practice, we recommend installing the latest AzureADPreview module. Type the following command at the PowerShell prompt:

      Install-Module AzureADPreview
    5. At the message about an untrusted repository, type Y.

      If you already have AzureADPreview installed, see the "update preview" instructions at the end of this article about how to uninstall the old version and get the new one. Otherwise, you're ready to go!

Set a user's password to never expire

  1. If you haven't already, open a Windows PowerShell window on your computer (it doesn't matter if it's a normal Windows PowerShell window, or one you opened by selecting Run as administrator).

  2. Run the following command:

  3. In the Sign in to your account page that opens, sign in with your Office 365 admin account, and click Sign in.

  4. Run the following command to set the password of one user to never expire:

    Set-MsolUser -UserPrincipalName <name of the account> -PasswordNeverExpires $true

    For example, if the name of the account is, you'd type the command like this:

    Set-MsolUser -UserPrincipalName -PasswordNeverExpires $true

    If you get a red error message, there's probably a typo or an extra space. Try again! Or, copy and paste the above to the PowerShell prompt, and use the arrow key to erase <name of the account> and enter the real name of the account.

  5. When you're successful, the PowerShell prompt appears for the next command. It doesn't display anything like "done" or "success."

Find out whether a user's password is set to never expire

  1. Run the following command:

  2. In the Sign in to your account page that opens, enter your admin credentials to connect to the service, and click Sign in.

  3. Run the following command:

    Get-MSOLUser -UserPrincipalName <user ID> | Select PasswordNeverExpires

    For example, to see the status for, you'd type the following:

    Get-MSOLUser -UserPrincipalName | Select PasswordNeverExpires

    The following picture shows how I set the password to never expire, and then ran the command to verify it is now set to never expire:

    This picture shows the commands to set the password to never expire, and then verify it was set.

Update preview version of Azure Active Directory Module for Windows PowerShell

The AzureADPreview module is required for a lot of procedures. As a best practice, we recommend always staying current: uninstall the old AzureADPreview version and get the latest one before you run PowerShell commands.

  1. To uninstall a previous version, run this command:

    Uninstall-Module AzureADPreview
  2. To install the latest version, run this command:

    Install-Module AzureADPreview

    At the message about an untrusted repository, type Y. It will take a minute or so for the new module to install.

The short icon for LinkedIn Learning. New to Office 365?
Discover free video courses for Office 365 admins and IT pros, brought to you by LinkedIn Learning.

Related articles

Set the password expiration policy for your organization

Let people reset their own passwords in Office 365

Expand your Office skills
Explore training
Get new features first
Join Office Insiders

Was this information helpful?

Thank you for your feedback!

Thank you for your feedback! It sounds like it might be helpful to connect you to one of our Office support agents.