never expire password office 365

How to set the password to never expire Office 365

PowerShell

Recently I’ve had to set a password to never expire (Which is not a good idea these days.) in Office 365 for a client. Normally this task would be simple if it was AD Sync’d. The Problem with this account is that it was made only in Office 365 and Azure AD.

So for one you simply can’t go to the AD server and click on the user and set the password to never expire. That would be to simple!

Microsoft has decided that it wants you to connect using PowerShell to complete which use to be a mundane task. For whatever reason, there is no button to simply click Never Expire in AzureAD.

Setting Password to Never Expire for Office 365 only accounts requires a Powershell Command. Powershell 5.1 is needed to complete this action. Follow these steps to change the password policy.

Steps to set the password to never expire Office 365

To complete this you must RUN POWERSHELL AS ADMINISTRATOR otherwise it won’t work!

Install-Module AzureAD

Hit Y Then Enter

Hit A Then Enter

Now Connect to your Office 365/Azure Domain using Domain Admin Credentials

$AzureAdCred = Get-Credential

Then

Connect-AzureAD -Credential $AzureAdCred

Now we must Check the users current password policy

Get-AzureADUser -ObjectId <INSERT EMAIL ADDRESS> | Select-Object @{N="PasswordNeverExpires";E={$_.PasswordPolicies -contains "DisablePasswordExpiration"}}

This next command will disable the password from expiring

Set-AzureADUser -ObjectId <INSERT EMAIL ADDRESS> -PasswordPolicies DisablePasswordExpiration

Use the Up Arrow to use the previous command to check for the password to be disabled!

Now your password is set to never expire in office 365!

Just in case if you are confused you need to remove the <INSERT EMAIL ADDRESS> and either use the username or email address you are wanting to use.

password to never expire Office 365

Here you can see me using the commands and even making the error of not connecting to the AzureAD domain before running the commands.

Conclusion

I hope this helps someone out there with this issue. Or at least saves them some time.

Took me a bit to figure out every little step along the way the more I get use to PowerShell the more I hope to provide people will cool guides and tips here.

join discord

Anyways if you want you can join the Discord and Follow me over on Twitter and give me a shout if this helped you out!

Twitter – @TheSmango

About Author

3 thoughts on “How to set the password to never expire Office 365

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.