Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2011-02-11
5
Medium Priority
?
421 Views
Last Modified: 2012-05-11
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
Comment
Question by:missymadi
  • 3
  • 2
5 Comments
 
LVL 27

Expert Comment

by:KenMcF
ID: 34873734
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
 

Author Comment

by:missymadi
ID: 34874259
How would I add a line that notifies the user that the script completed?
0
 
LVL 27

Expert Comment

by:KenMcF
ID: 34874365
The user running the script or the user that is having the password changed?
0
 

Author Comment

by:missymadi
ID: 34874466
The user running the script.
0
 
LVL 27

Accepted Solution

by:
KenMcF earned 2000 total points
ID: 34874547
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

Featured Post

New Tabletop Appliances Blow Competitors Away!

WatchGuard’s new T15, T35 and T55 tabletop UTMs provide the highest-performing security inspection in their class, allowing users at small offices, home offices and distributed enterprises to experience blazing-fast Internet speeds without sacrificing enterprise-grade security.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
A recent project that involved parsing Tableau Desktop and Server log files to extract reusable user queries for use in other systems. I chose to use PowerShell to gather the data, and SharePoint to present it...
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Screencast - Getting to Know the Pipeline

876 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question