Link to home
Start Free TrialLog in
Avatar of GSW Dubs
GSW DubsFlag for United States of America

asked on

Changing users password using powershell and a csv file

Hi,

I created multiple user accounts in AD using PowerShell and a CSV file. Now I need help modifying the same PowerShell script so I can change every user's password in the CSV file.
I attached the original script I used for the accounts creation.

Thanks!
Avatar of yo_bee
yo_bee
Flag of United States of America image

This should work as long as your CSV has a column username and password

Import-Module activedirectory
$users = Import-Csv -Path  C:\temp\ADUsers.csv

Foreach ($user in $users)
{

$SecurePassword=ConvertTo-SecureString $user.password –asplaintext –force 
Set-ADAccountPassword -Identity $user.Username -NewPassword $SecurePassword  

}

Open in new window

Avatar of GSW Dubs

ASKER

Thank you for your response!
When I run your script it prompts you to enter the new password for each user. I already change the passwords in my CSV file. I need a script that will automatically take the new password from the file. The CSV file has more 120 records.
ASKER CERTIFIED SOLUTION
Avatar of yo_bee
yo_bee
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hey yo_bee,

Yes, it works! I just tested it. Thanks a lot!!!
Glad to help