Confirm All Users have PasswordNeverExpires

So with PowerShell we can grant users the policy of PasswordNeverExpires, which in some cases are good enough security. Perhaps togethere with a second factor for authentication.

PS Command: Get-MsolUser | Set-MsolUser -All -PasswordNeverExpires $true ($false will do the upposite).


But later you might wanne confirm all users have PasswordNeverExpires or some users should change their Passwords regularly.

PS Command: Get-MsolUser | Select UserPrincipalName, PasswordNeverExpires

Output would be for example:



To change some users back to PasswordExpires: Get-MsolUSer -UserPrincipalName | Set-MsolUser -PasswordNeverExpires $false

Leave a Reply


I am Roy Apalnes, a Microsoft Cloud Evangelist working av Sopra Steria. Main focus in Microsoft Security and Endpoint Management, with a bigger picture in mind.

Featured Posts