Check if the password is set to never expire for one user:
Get-MSOLUser -UserPrincipalName username | Select PasswordNeverExpires
Check if the password is set to never expire for all users:
Get-MSOLUser | Select UserPrincipalName, PasswordNeverExpires
Check if the password is set to never expire for a list of users:
create a txt file listing the required users, line by line with title “username”, and save it as c:pwdexpire.txt, like this:
username
testuser1
testuser2
testuser3
then run:
Import-csv c:pwdexpire.txt | for each { Get-MSOLUser -UserPrincipalName $_.username | Select PasswordNeverExpires }
Set password to never expire for one user:
Set-MsolUser -UserPrincipalName username -PasswordNeverExpires $true
Set password to never expire for all users:
Get-MSOLUser | Set-MsolUser -PasswordNeverExpires $true
Set password to never expire for a list of users:
like before create a txt list and run:
Import-csv c:pwdexpire.txt | for each { Set-MsolUser -UserPrincipalName $_.username -PasswordNeverExpires $true }
to re-set the password to expire just replace the $true with $false (please note that is the organization’s password expiration period has passed then the user/users will be locked and you will need to reset their passwords)
Pantelis Apostolidis is a Sr. Specialist, Azure at Microsoft and a former Microsoft Azure MVP. For the last 20 years, Pantelis has been involved to major cloud projects in Greece and abroad, helping companies to adopt and deploy cloud technologies, driving business value. He is entitled to a lot of Microsoft Expert Certifications, demonstrating his proven experience in delivering high quality solutions. He is an author, blogger and he is acting as a spokesperson for conferences, workshops and webinars. He is also an active member of several communities as a moderator in azureheads.gr and autoexec.gr. Follow him on Twitter @papostolidis.