Link to home
Start Free TrialLog in
Avatar of cawasaki
cawasaki

asked on

powershells cript to modify password for AD users from csv file

hello,

i have windows 2008 r2 domain controller

i need a powershell script to modify an AD user password from csv file.

the csv are in this form:

user1,password
user2,password
....
where user1 is a samacountname.

if possible i need a log file to see if it sucess like this:

user1, password changed
user2,password changed
user3, password not changed (for exemple if not respect password policy)


thanks for help
Avatar of jss1199
jss1199

I use Quest's (now Dell) AD cmdlets (freeware) - http://www.quest.com/powershell/activeroles-server.aspx

$changepass = Import-csv "C:\new_user_pass.csv"

foreach($line in $changepass) {set-QADUser $line.username -UserPassword $line.password } 

Open in new window

SOLUTION
Avatar of Will Szymkowski
Will Szymkowski
Flag of Canada 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
Avatar of cawasaki

ASKER

@spec01

the file must be in this form: ???

sAMAccountName,Password
jdoe,password
steph,password
....

???

and for log file?
The sAMAccountName and Password are headings in the CSV file (column A would be sAMAccountName comlum B would be Password). There are no "," between the headings, they are heading for different columns. You then put the respective names/passwords under each heading.

As for the logging, if the password change fails you will get an error stating the name where it failed in the powershell window.

Will.
hi,

sorry i dont understand, in the csv file you put many space:

sAMAccountName    Password
jdoe                           P@ssword
etc...

may be it an excel file?
You may create the file in excel, the the two columns specified.  Simply save as type CSV
I put spaces in my post on here to illustrate the sepration between the columns. In Excel (saved as a CSV file) you have columns A B C D etc. Use the first 2 columns A and B and put in your headings as i have described above. Continue this pattern for the actual users and passwords under there respective headings.

Will.
Ok i will test.
Its possible to get a log file because if i lunsh the script for 100 account i cannot see all pn screen :)
Thanks for help
ASKER CERTIFIED SOLUTION
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
hello,

so i have an excel file, i put a column to samaccountname and one for password, after that i need to save file to csv, but i have many csn file option like csv dos, csv macintosh...

wish one i choose?

thanks
Probably doesn't make a difference, but I wouldn't choose the Mac one.  Either ".CSV (Comma delimited)" or ".CSV (MS-DOS)" should work for you.
thank you