Set Password of Azure Active Directory B2B User to Not Expire with PowerShell


First up, non-expiring passwords aren’t recommended… but, what if you did want to set an AAD user to have a non-expiring password? Furthermore, what if you wanted to target a B2B user?
 
Here’s how I get a list of my B2B users, that have a display name starting with Ian, that also have their password set to expire…
 


Get-AzureADuser -Filter "creationtype eq 'invitation' and startswith(displayName,'Ian')" | 
Where-Object {$_.PasswordPolicies -ne "DisablePasswordExpiration"} | 
Format-Table UserPrincipalName,DisplayName,CreationType,UserType,PasswordPolicies

 

capture215_a
 

Now, to use the redacted UserPrincipalName to target the user and set their password to not expire…
 


Set-AzureADuser -ObjectID //RedactedUpn// -PasswordPolicies DisablePasswordExpiration 

 

clip_image100
 

Comments (0)

Skip to main content