Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 423
  • Last Modified:

How do I include many user names to my Powershell script to reset Passwords?

Experts,

       How do I add more users to my script to update their password?

Thanks, Missymadi
$users = get-qaduser -samaccountname USERNAME 
$users | %{
set-qaduser -Userpassword 'Test'
get-qaduser -samaccountname $_.samaccountname | Select samaccountname, passwordlastset | out-file c:\PwdChanged.txt -noclobber
}

Open in new window

0
missymadi
Asked:
missymadi
  • 3
  • 2
1 Solution
 
KenMcFCommented:
You can do it a few ways

$users = get-qaduser -searchbase "OU=Users_OU,DC=Domain,DC=Local"

$users = get-content c:\users.txt

$users = @(
"User1"
"User2"
"User3"
)
0
 
missymadiAuthor Commented:
How would I add a line that notifies the user that the script completed?
0
 
KenMcFCommented:
The user running the script or the user that is having the password changed?
0
 
missymadiAuthor Commented:
The user running the script.
0
 
KenMcFCommented:
You can write it out to the console

$users | %{  
set-qaduser -Userpassword 'Test'  
Write-host "$($_) password was reset"
get-qaduser -samaccountname $_.samaccountname | Select samaccountname, passwordlastset | out-file c:\PwdChanged.txt -noclobber  
}
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now