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.

2 Answers 2

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.

  • 1
    +1 Dead simple, and should work great!
    – sysadmin1138
    Jul 22, 2010 at 22:21
  • 1
    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, 2010 at 22:24
  • 1
    +1 I like dead simple Jul 22, 2010 at 22:26
  • @JT.WK: Updating my answer...
    – jscott
    Jul 22, 2010 at 22:32
  • 1
    +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, 2010 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.

  • 1
    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? Jul 22, 2010 at 22:29
  • true but was pointing in a good direction thanks for the -1 Jul 22, 2010 at 22:34
  • 2
    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. Jul 23, 2010 at 1:24
  • 2
    "...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, 2010 at 11:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .