Reputation: 57
I want to find a PowerShell script to find the user password expiry date and time and renew it to customized time for bulk users.
I tried it with with the below code:
Get-MsolUser -UserPrincipalName '[email protected]' | select *password* |fl
This can fetch only last password change but not when the password will expire.
Upvotes: 0
Views: 3828
Reputation: 129
There is no field you can query for this task. You have to do this in two steps.
Get the password policy
$PasswordPolicy = Get-MsolPasswordPolicy
Calculate the time to the next password expiry date with some math magic
$(Get-MsolUser -UserPrincipalName "SuperUser").LastPasswordChangeTimestamp.AddDays($PasswordPolicy.ValidityPeriod)
More details can be found here Office 365 – Retrieve User Password Expiration Date
Upvotes: 1