Forum Discussion

talobau's avatar
talobau
Copper Contributor
Jul 08, 2024
Solved

Can't change PasswordExpirationPolicy of all users with Update-MgUser

Hello,   Ive got into a problem where we disabled Password expiration in the GUI but some account keep having it enabled when you look with Powershell. Microsoft provides a guide where they explain...
  • talobau's avatar
    Jul 08, 2024

    I found the solution for it

    first you download a CSV file of every User in your tenant.

    Get-MGuser -All -Property UserPrincipalName | 
    Select-Object UserprincipalName | 
    ConvertTo-Csv -NoTypeInformation | 
    Out-File /Users/username/Downloads/UPN.csv

    after you have that file you use it to scope all users in your tenant and apply the change

    Import-Csv “/Users/username/Downloads/UPN.csv” | ForEach-Object{
    $UserPrincipalName = $_.UserPrincipalName
    Update-MgUser -UserId $UserPrincipalName -PasswordPolicies DisablePasswordExpiration }

     

Resources