Link to home
Start Free TrialLog in
Avatar of Leo
LeoFlag for United States of America

asked on

Powershell Get-ADUser to change attribute for AD accounts in several OUs


I need to change the attribute "EmployeeType" to a value "A3341" for all the AD accounts that are part of two different OU, for example OU1 and OU2.  I was trying to do it with Get-ADUser but I can't get it two work. 

Can someone please help? 

Thank you!

Avatar of oBdA

This should do it. It's in test mode and will not actually change anything; remove the -WhatIf at the end of line 3 to run it for real.
$OUs = 'OU=OU1,OU=Parent1,DC=domain,dc=com', 'OU=OU2,OU=Parent2,DC=domain,dc=com'
ForEach ($ou in $OUs) {
	Get-ADUser -Filter * -SearchBase $ou | Set-ADUser -Replace @{employeeType='A3341'} -Verbose -WhatIf

Open in new window

Avatar of Leo


thank you so much! is there any way we could log any errors in some text log?
Avatar of oBdA

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial