Jump to content

Recommended Posts

Posted

Hi gang,

 

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()
   $usr.SetPassword($user.password)
   $usr.SetInfo()
}

 

cheers

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...