Solved

Powershell Script not executing as expected

Posted on 2011-02-14
1
408 Views
Last Modified: 2012-05-11
Experts,

      the code below is not executing as expected. I am getting an error "cmdlet set -qaduser at command pipeline position supply values for following parameters  Identity:

I expected the code to just go through and change the two users to the new password and write both password changes to the text file. I am only getting one user change being piped out to text file.

Please advise
Missymadi
$users = @(
"Reset1"
"Reset2"
) 
$users | %{
set-qaduser -Userpassword 'Test'
Write-host "$($_) password was reset"
get-qaduser -samaccountname $_.samaccountname | Select samaccountname, passwordlastset | out-file c:\ResetCrew.txt -noclobber
}

Open in new window

0
Comment
Question by:missymadi
1 Comment
 
LVL 27

Accepted Solution

by:
KenMcF earned 500 total points
ID: 34892346
Without testing it looks like you are missing one part, just add get-qaduser like below and test.

$users = @(  
"Reset1"  
"Reset2"  
)  
$users | %{  
get-qaduser -samaccountname $_ | set-qaduser -Userpassword 'Test'  
Write-host "$($_) password was reset"  
get-qaduser -samaccountname $_.samaccountname | Select samaccountname, passwordlastset | out-file c:\ResetCrew.txt -noclobber  
}
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article outlines the process to identify and resolve account lockout in an Active Directory environment.
A project that enables an administrator to perform actions within a user session context not just at the time of login but any time later on day(s) or week(s) later.
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

730 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