I have run the following cmdlet in PowerShell to disable the Password Expiration policy in my M365 tenancy for all users. However, the cmdlet is not applied to new users created. Can someone please explain how I can disable the policy for all current and new users?
Get-AzureADUser -All $true | Select-Object UserprincipalName,@{
N="PasswordNeverExpires";E={$_.PasswordPolicies -contains "DisablePasswordExpiration"}
}
EDIT
I have unchecked the Set user passwords to expire after a number of days in the Password expiration policy page. I have run the following cmdlet to check this policy is turned off in PowerShell.
Get-MsolPasswordPolicy
I have run the following cmdlet to set a Password to Never Expire Policy for all users in the organisation. (Upon investiation, this policy only applies to current users, and will not apply to new users).
Get-AzureADUser -All $true | Set-AzureADUser -PasswordPolicies DisablePasswordExpiration
Next I have checked the Set Password to Never Expire policy has been implemented successfully:
Get-AzureADUser -All $true | Select-Object UserprincipalName,@{
N="PasswordNeverExpires";E={$_.PasswordPolicies -contains "DisablePasswordExpiration"}
}
I then created a new user in M365 and ran the same cmdlet again. I can now see that the new user does not have the Password to Never Expire Policy applied.
Is there a cmdlet to create a Password to Never Expire for all users (current and new users)? I don't want to create separate policies for different users, I want to apply the same policy to all. Please advise.