Configure MS Online User Expire Option for Passwords

Use the Microsoft Online Services Module for Windows PowerShell to set up and remove the user password expire option.

Only passwords for user accounts that are not synchronized through directory synchronization can be configured to never expire.

 

Use Windows PowerShell to Manage Office 365. Make sure that you are using the PowerShell version that you downloaded from the download site in the Admin Portal.

  1. Right click the shortcut to ‘Microsoft Online Services Module for Windows PowerShell’ from the desktop and select “Run as Administrator…”
  2. Set the Execution Policy for the local server to Remote Signed
  3. Set-ExecutionPolicy –ExecutionPolicy RemoteSigned
  4. Set your credential Variable
  5. $cred=Get-Credential
  6. Enter the Username and password for the global admin account on Office 365 when prompted
  7. Connect to Microsoft Online Services with the credential variable set previously
  8. Connect-MsolService – Credential $cred

 

PowerShell Commands

Check to see if a user’s password is set to never expire
Get-MSOLUser -UserPrincipalName <user ID> | Select PasswordNeverExpires

Check to password is set to never expire for all users
Get-MSOLUser | Select UserPrincipalName, PasswordNeverExpires

Set a password to never expire for a user
Set-MsolUser -UserPrincipalName <user ID> -PasswordNeverExpires $true

Set a password to never expire for all users

Get-MSOLUser | Set-MsolUser -PasswordNeverExpires $true

Set a password to expire for a user 
Set-MsolUser -UserPrincipalName <user ID> -PasswordNeverExpires $false

Set a password to expire for all users
Get-MSOLUser | Set-MsolUser -PasswordNeverExpires $false

Thanks for visiting and reading my posts. I am always looking for more ideas. Please comment or email me with what you would like to see.

Kelsey Epps

Office 365 MVP

Email Me Follow me on Twitter Connect with me on LinkedIN Facebook Me

Leave a Reply