Freigeben über

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

Anonym
2024-07-08T07:34:15+00:00

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 hot to set all users policy to never expire, sadly it doesn't work, I've tried it in several Tenants already.

Here is the link to the guide:

https://learn.microsoft.com/en-us/microsoft-365/admin/add-users/set-password-to-never-expire?view=o365-worldwide

The command:

Get-MGuser -All | Update-MgUser -PasswordPolicies DisablePasswordExpiration

The error when the command is used:

Update-MgUser_UpdateViaIdentityExpanded: The pipeline has been stopped.

Exception: InputObject has null value for InputObject.UserId

I know that you should set a UserID as a scope for it to work, but this isn't possible as far as I know on update-mguser. Please help me find a solution to update everyone's PasswordExpirationPolicy to never expire.

I was thinking about creating a script that goes through every userid and performs the action, but my knowledge isn't as advanced to create it.

Microsoft 365 und Office | Publisher | Für das Bildungswesen

Gesperrte Frage. Diese Frage wurde aus der Microsoft-Support-Community migriert. Sie können darüber abstimmen, ob sie hilfreich ist, aber Sie können keine Kommentare oder Antworten hinzufügen oder der Frage folgen.

0 Kommentare Keine Kommentare
{count} Stimme
Antwort, die vom Frageautor angenommen wurde
  1. Anonym
    2024-07-08T12:59:18+00:00

    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 }
    
    2 Personen fanden diese Antwort hilfreich.
    0 Kommentare Keine Kommentare

1 zusätzliche Antwort

Sortieren nach: Am hilfreichsten
  1. Anonym
    2024-07-09T09:15:59+00:00

    Hallo Lautaro,

    vielen Dank für deine Anfrage und die geteilete Lösung. Holffentlich wird diese Infotrmation auch andere Nutzer mit solchen Fragen helfen.

    Mit freundlichen Grüßen

    Alexander Petrov

    Microsoft Office 365 Business Support Engineer

    0 Kommentare Keine Kommentare