TerminalProtocol

SetPass

Apr 5th, 2017
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Import the CSV File with all the stuff.
  2. Import-CSV C:\Temp\Test.csv
  3. # Initiate a ForEach Loop.
  4. ForEach ($User in $Users){
  5. # Invoke the command to actually change passwords.
  6. # The following will select each account (Users column), and "Reset" the password to the corresponding string in the "Password" column.
  7. Set-ADaccountPassword -Identity $User -Reset -NewPassword (ConvertTo-SecureString -AsPlainText $Password -Force)
  8. #If you want to check the "Force User to Change Password on Next Login" box, un-comment the next line.
  9. # Get-ADUser $User | Set-ADUser -ChangePasswordAtLogon $true
  10. }
Advertisement
Add Comment
Please, Sign In to add comment