Change AD users attributes via Power Shell script
This is an example for a single user. Use filters or otherwise get a list of users, explicitly request the regulationMatrix property and then pipe the whole thing into the Set-ADUser
command. Use -Replace
or -Add
to modify the property.
Get-ADUser j.doe -Properties regulationMatrix | Set-ADUser -Replace @{regulationMatrix="Hurz"}
Related videos on Youtube
![Cranta Ionut](https://lh6.googleusercontent.com/-7FoyUuxf10c/AAAAAAAAAAI/AAAAAAAAAB4/49NgBdrPCfo/photo.jpg?sz=256)
Cranta Ionut
I work as a system admin in an IT services company. I started 6 months ago from scratch with no professional background. I heard of Stack Exchange sites for some time now and finally decided to a proud member of it.
Updated on September 18, 2022Comments
-
Cranta Ionut almost 2 years
In the domain I'm working we created an attribute "regulationMatrix" . When I try a powershell command like get-aduser USER -properties * that specific attribute shows up only if it has a value set like "regulationMatrix : {PIC}", if not it doesn't appear on the output.
The attribute was recently added and now i have to add this attribute to 1000 users from a single OU.
Could someone help me with a script or command for example to modify the attributes to all users from the specific OU.
Thank you.
$userlist = get-aduser -searchbase "OU=RandomOU,DC=contoso,DC=europa,DC=net" -filter * -properties regulationMatrix foreach ( $users in $userlist ) { $username = $users.samaccountname $reg = $users.regulationmatrix write-host $username write-host $reg set-aduser -identity $username -add @{'regulationMatrix'='PIC'} }
Thanks to Daniel i figured what to add, this worked perfectly.