Set Password Never Expire for Office 365 Users with AzureAD PowerShell V2 Module

In this blog post, I’ll show you how to set the password of an Office 365 account ord to never expire using the Azure Active Directory PowerShell V2 Module.

Settings Password Never Expire on a user account Is not recommended to apply to users however In some cases like when using Service Accounts you might want to use it.

In my case, I’ll configure a Service account to have its password to never expire using the AzureAD PowerShell module.

Get started

To get started, I’ll connect to Office 365 using PowerShell.


The first step In this process Is to find the user Object Id using the cmdlet below:

Get-AzureADuser -searchstring "svc"

Next, I’ll copy the objectId and will use it in the cmdlet below:

Set-AzureADUser -ObjectId f993773e-4f00-47c4-b04d-4d775b655ca5 -PasswordPolicies disablepasswordexpiration

To verify that it worked using the cmdlet below:

get-AzureADUser -ObjectId f993773e-4f00-47c4-b04d-4d775b655ca5 | select password*

To the password expiration policy on all users, run the cmdlet below:

Get-AzureADUser | select UserPrincipalName , PasswordPolicies

Note: If you are using version 1 of the module also known as Msonline use the cmdlet below:

Set-MsolUser -UserPrincipalName -PasswordNeverExpires $true

Leave a Reply