Forum Discussion

ABill1's avatar
ABill1
Iron Contributor
Oct 24, 2023
Solved

How to change user passwords in bulk - without force to change

Hello everyone,

 

I'm in the process of updating the passwords for multiple users, and I'd like to set specific passwords of my choice. Additionally, I want to ensure that these accounts won't prompt users to change their passwords upon their first login.

 

I'd greatly appreciate your assistance, as the scripts I previously used are no longer effective.

  • Hi Kidd_Ip darlene22xx 

     

    I tried them however they didnt work anymore for me I had to use: Import-Csv ".\Sample7users.csv" -Delimiter "," -Encoding UTF8 | ForEach-Object {
            $user = Get-AzureADUser -Filter "userPrincipalName eq '$($_.upn)'"
            $secureString = ConvertTo-SecureString ($_.pw) -AsPlainText -Force
            Set-AzureADUserPassword -ObjectId $user.ObjectID -Password $secureString -ForceChangePasswordNextLogin $false
        }

     

  • ABill1's avatar
    ABill1
    Iron Contributor

    Hi Kidd_Ip darlene22xx 

     

    I tried them however they didnt work anymore for me I had to use: Import-Csv ".\Sample7users.csv" -Delimiter "," -Encoding UTF8 | ForEach-Object {
            $user = Get-AzureADUser -Filter "userPrincipalName eq '$($_.upn)'"
            $secureString = ConvertTo-SecureString ($_.pw) -AsPlainText -Force
            Set-AzureADUserPassword -ObjectId $user.ObjectID -Password $secureString -ForceChangePasswordNextLogin $false
        }

     

  • darlene22xx's avatar
    darlene22xx
    Copper Contributor
    Hi ABill1,

    To do bulk password reset, you need to create a CSV file where it should have a column preset with passwords, we will use this command, provided the column header is named “Password".

    Import-Csv "C:\Users.csv" | % { Set-MsolUserPassword -userPrincipalName "$_.UserPrincipalName" -NewPassword "$_.Password" -ForceChangePassword $False

    As you noticed, ForceChangePassword was set to false hence it should not force the users to change password the next time they sign in.

Resources