Microsoft Office 365 logo

How to Set Office 365 Users Password Expiration Policy to Never Expire with PowerShell

By default, Office 365 users password are expired after 730 days. However, you can change the settings from Security & privacy tab in admin center.

This article is written to help you set Office 365 users password to never expire with the help of PowerShell.

Prerequisites

Download and install the following PowerShell modules on your machine.

  1. Microsoft Online Service Sign-in Assistant for IT Professionals RTW
  2. Windows Azure Active Directory Module for Windows PowerShell (64-bit version)

Step-By-Step

1. Open PowerShell with elevated privileges and execute the following command to connect to office 365 subscription.

Connect-MsolService

When you are prompted, provide a global administrator account username and password.

2. When you are successfully connected, issue the following command to set all users password expiration policy to never expire.

Get-MSOLUser | Set-MsolUser -PasswordNeverExpires $true

3. To verify, issue the following command on PowerShell.

Get-MSOLUser | Select UserPrincipalName, PasswordNeverExpires

 

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish