Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Need to Modify Powershell Script to Reset Passwords for Active Directory Users in Child Domain

Avatar of advserver
advserverFlag for United States of America asked on
Windows Server 2003Active DirectoryPowershell
6 Comments1 Solution1144 ViewsLast Modified:
I have pasted below a Powershell script which resets users passwords and forces to change at next logon.  
The script uses a csv file for the list of users.  
The script worked in the test environment but the production environment has a child domain where the scripts intended users reside.
What changes must be made in order for this script to be able to reset passwords for users in a child domain and force their password to change at next logon?

*** I cannot use Quest cmdlets***

Import-csv users.csv | foreach {
$Searcher = New-Object DirectoryServices.DirectorySearcher 

  $Searcher.Filter = "(sAMAccountName=$($_.Username))" 
 
  $Result = $Searcher.FindOne() 
  $User = $Result.GetDirectoryEntry() 
 
  $User.SetPassword("Password!") 
  $User.Put("pwdLastSet", 0) 
  $User.SetInfo() 
}
ASKER CERTIFIED SOLUTION
Avatar of Chris Dent
Chris DentFlag of United Kingdom of Great Britain and Northern Ireland imagePowerShell Developer
Commented:
This problem has been solved!
Unlock 1 Answer and 6 Comments.
See Answers