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.
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.