Manage Office 365 password expiration

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)

Share

Leave a Reply

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

three − three =