(Bulk) Change user passwords using csv
I need to change all the staff and student passwords using a csv file I created last night.
I need a script that will basically look at coloum1 for the username to search for that username and then use coloum 2 to change the users password.
here is a script I found. Does this look like it will do the job?
foreach($user in (import-Csv C:\UPass.csv))
Write-Host "Setting Password for $($User.username)"
$ds = new-Object System.DirectoryServices.DirectorySearcher([ADSI]"","(&(objectcategory=user)(sAMAccountName=$($user.username)))")
$usr = ($ds.Findone()).GetDirectoryEntry()