Occasionally we’ll be required to set a user account on Office365 to never expire. It’s not advisable to perform this action, as a compromised account who’s passwords never expires can be a liability. However, in some cases a utility account such as a scanner/copier or kiosk account may require a password that does not change. The following tutorial will show you how to set an Office365 password to never expire using PowerShell.
First, we’ll want to ensure that the account password is not already set to expire and we want to confirm it’s status. Using PowerShell we can get information about an Office365 user account password expiration status.
1. Connect to Microsoft Online Services with PowerShell by running the following commands:
Import-Module MSOnline Connect-MsolService
2. Next, replace <UserID> with the user account (email address) of the user’s properties we want to get with the following command:
Get-MsolUser -UserPrincipalName <user ID> | Select PasswordNeverExpires
Our result should look like the following:
3. Because we get the message returned that the property PasswordNeverExpires = False, we want set it to $True and set the account password to never expire with the following command:
Set-MsolUser -UserPrincipalName <[email protected]> -PasswordNeverExpires $true
Again, change the <[email protected]> identifier to the email address of the account you want to change. Our result will not produce an output:
4. To verify the account password will no longer expire, we’ll run our first command again to see the result:
Get-MsolUser -UserPrincipalName <user ID> | Select PasswordNeverExpires
Our result should look similar to the following:
Because our PasswordNeverExpires property is now set to True, our task is complete. Disconnect from Office365 and close powershell by entering the command: exit.