Set a single O365 account password to never expire

Powershell

      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).              

      Run the following command:                 

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


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 Ina@contoso.com, you'd type the command like this:               
Set-MsolUser -UserPrincipalName Ina@contoso.com -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.


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    

Run the following command:                  

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


Run the following command               

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


For example, to see the status for Ina@contoso.com, you'd type the following:
                  
Get-MSOLUser -UserPrincipalName Ina@contoso.com | Select PasswordNeverExpires
        
Was this article helpful?