Powershell - how to set multiple action on get-aduser "dataset"

Posted by Patrick Pellegrino on Server Fault See other posts from Server Fault or by Patrick Pellegrino
Published on 2012-11-01T21:16:21Z Indexed on 2012/11/27 23:11 UTC
Read the original article Hit count: 107

I'm trying to run a script that modify password for multiple AD user accounts, enable the accounts and force a password change at next logon.

I use this code but that's not work :

Get-ADUSER -Filter * -SearchScope Subtree -SearchBase "OU=myou,OU=otherou,DC=mydc,DC=local" | Set-ADAccountPassword -Reset -NewPassword (ConvertTo-SecureString -AsPlainText "NewPassord" -Force) | Enable-ADAccount | Set-ADUSER -ChangePasswordAtLogon $true

If I run the Get-ADuser line with ONLY one of the other line that's run fine ex :

Get-ADUSER -Filter * -SearchScope Subtree -SearchBase "OU=myou,OU=otherou,DC=mydc,DC=local" | Enable-ADAccount

Where I'm wrong ? I'm new to PowerShell probably I'm misunderstanding something.

© Server Fault or respective owner

Related posts about active-directory

Related posts about powershell