There are two tools for this job, both Joeware (www.joeware.net). Grab adfind and admod and extract them to the same directory.

The first task is to get the logonhours attribute value you want to set. The easiest way is to set it by hand in ADUC on one user, and then use adfind to dump the value, with a command like this:

adfind -b “OU=Staff,OU=Users,DC=BigTire,DC=local“ -h “my-dc01” -f "(&(objectCategory=person)(objectClass=user)(samaccountname=templateusername))" logonhours

Copy and paste that somewhere, you'll need it later. If you just want to set it to 24/7 as I'm going to do, the value is “FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FF“.

That done, we can update all the users we want to modify. We'll pipe the output from adfind over to admod.

adfind -b “OU=Staff,OU=Users,DC=BigTire,DC=local“ -h “my-dc01” -f "(&(objectCategory=person)(objectClass=user))" -dsq | admod -h my-dc01 -safety 100 bin##logonhours::"FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FF"

Note that we added a -dsq switch which tells adfind to just pipe the dn's of the users matching our filter (everybody in the staff OU in this case). the bin## is a special instruction for admod so it knows to do a binary attribute update. Finally, -safety 100 tells admod only to modify the first 100 objects passed to it. You can replace this with -unsafe to do every object, or increase the safety limit.