Solved

Powershell Script not executing as expected

Posted on 2011-02-14
1
403 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
Comment Utility
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Microsoft Windows Server Update Service (WSUS) is free for everyone, but it lacks of some desirable features like send an e-mail to the administrator with the status of all computers on the WSUS server. This article is based on my PowerShell script …
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
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 …

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now