9

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.

JT.WK
  • 431
  • 6
  • 18

2 Answers2

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

jscott
  • 24,484
  • 8
  • 79
  • 100
-1

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

jer.salamon
  • 449
  • 4
  • 12
  • 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? – WheresAlice 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
  • 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. – John Gardeniers Jul 23 '10 at 01: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 '10 at 11:56