Office 365

Office 365 | Configure Permanent Passwords

| | Leave a comment

Office 365 doesn’t allow you to set passwords that do not expire through the GUI – the maximum you can configure here is 730 days. However, if you would like to set passwords to not expire, you can do so via PowerShell:


To set passwords for an individual 365 user to never expire:

Import-Module msonline

$cred = Get-Credential

Connect-MsolService -cred $cred

Get-MsolUser | Where { $_.PasswordNeverExpires –ne $true } | Format-Table DisplayName, PasswordNeverExpires, UserPrincipalName

[the above command shows all the user accounts with passwords set to expire]

Set-MsolUser –UserPrincipalName [UPN name, usually the main email address of the target user] –PasswordNeverExpires $true

To set passwords for an entire 365 organisation to never expire:

​​Import-Module msonline

$cred = Get-Credential

Connect-MsolService -cred $cred

Get-MsolUser | Where { $_.PasswordNeverExpires –ne $true } | Format-Table DisplayName, PasswordNeverExpires, UserPrincipalName

Get-MsolUser | Where { $_.PasswordNeverExpires –ne $true } | Set-MsolUser –PasswordNeverExpires $true

The above will work if you’re an administrator on that tenant, but what about if you’re delegated administrator on a client’s 365 platform? In that case, use the following:

To set passwords for an individual 365 user to never expire (partner access):

Import-Module msonline

$cred = Get-Credential

Connect-MsolService -cred $cred

$domain = [domain name of the client you’d like to make changes on behalf of]

$Customer = (Get-MsolPartnerContract –DomainName $domain).TenantId

Get-MsolUser -TenantId $Customer | Where { $_.PasswordNeverExpires –ne $true } | Format-Table DisplayName, PasswordNeverExpires, UserPrincipalName

Set-MsolUser -TenantId $Customer​ –UserPrincipalName [UPN name, usually the main email address of the target user] –PasswordNeverExpires $true

To set passwords for an entire 365 organisation to never expire (partner access):

Import-Module msonline

$cred = Get-Credential

Connect-MsolService -cred $cred

$domain = [domain name of the client you’d like to make changes on behalf of]

$Customer = (Get-MsolPartnerContract –DomainName $domain).TenantId

Get-MsolUser -TenantId $Customer | Where { $_.PasswordNeverExpires –ne $true } | Format-Table DisplayName, PasswordNeverExpires, UserPrincipalName

Get-MsolUser -TenantId $Customer | Where { $_.PasswordNeverExpires –ne $true } | Set-MsolUser –PasswordNeverExpires $true


If you’re having any further issues with your 365 deployment, please don’t hesitate to get in touch with the team here at Program Framework.