Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I was wondering if there is a way to update the 'Company' field for a large group of users within Active Directory? I would like to match all users with a company ending in a certain string.

It would take way too long to change this for each user individually.

share|improve this question
up vote 13 down vote accepted
dsquery user -name * -limit 0 | dsmod user -company "%COMPANY%"

Adjust the dsquery to target specific users as required.

Edit: To match on a specific [sub-]string

dsquery * -filter "&((objectCategory=Person)(objectClass=User)(company=*OLDCOMPANY))" -limit 0 | dsmod user -company "%NEWCOMPANY%"

Adjust the *OLDCOMPANY regex to suit your needs.

share|improve this answer
+1 Dead simple, and should work great! – sysadmin1138 Jul 22 '10 at 22:21
Thanks for the suggestion - playing with it now. Can this be modified to only change users where the company ends with a particular string? – JT.WK Jul 22 '10 at 22:24
+1 I like dead simple – jer.salamon Jul 22 '10 at 22:26
@JT.WK: Updating my answer... – jscott Jul 22 '10 at 22:32
+1 Win. I was about to write the same thing using Find, DSQuery, DSGet, and DSMod - but yours is a much more elegant solution – Izzy Jul 22 '10 at 22:35

Write a powershell script to change it for all users where the company = the old company name to the new company name.

share|improve this answer
Well yeah, you probably could do something in powershell. But that in itself isn't a helpful answer - what are the powershell commands for searching and modifying users? – kaerast Jul 22 '10 at 22:29
true but was pointing in a good direction thanks for the -1 – jer.salamon Jul 22 '10 at 22:34
A cryptic reference to an an even more cryptic scripting language, with no real information about solving the problem is not a good answer - ever. I'll credit it to inexperience rather than downvote it. – John Gardeniers Jul 23 '10 at 1:24
Thanks its what I get for answering and driving – jer.salamon Jul 23 '10 at 2:12
"...answering and driving" -- As in while driving a motor vehicle? Please don't do that, it's incredibly dangerous to yourself and others on the road. – jscott Jul 23 '10 at 11:56

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.