Link to home
Start Free TrialLog in
Avatar of cavalierlan
cavalierlan

asked on

Use dsquery dsmod

I'm trying to pipe a dsquery to a dsmod to change the company attribute of all users in a certain OU.

If I type: (removed my domain name for posting)
dsquery user "ou=Cav USERS TEST,ou=Cavalier USERS,ou=Cavalier,dc=domain,dc=domain,dc=domain,dc=domaindc=domain"
I got a list of the four test users returned from this query.

I then | that to a dsmod -company mycompanyname.  This looks like this
dsquery user "ou=Cav USERS TEST,ou=Cavalier USERS,ou=Cavalier,dc=domain,dc=domain,dc=domain,dc=domaindc=domain" | dsmod -company mycompanyname

This returns an error
dsquery failed:A referral was returned from the server.

I've tried it a number of different ways, but can't get it to work

What's the proper syntax to get the dsmod to change the company attribute for all users in a certain OU?
ASKER CERTIFIED SOLUTION
Avatar of Farhan Kazi
Farhan Kazi
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi,

aren't you missing "user" in dsmod USER -company etc? I know you are getting the userlist from DSQUERY, but you should specify DSMOD USER anyway, it's a switch.
Avatar of cavalierlan
cavalierlan

ASKER

I got it.

I had to add -name * at the end of the dsquery before | dsmod
No, "DSQuery OU -Name *" will list all OU in domain with its correct DN. So you note correct DN and then put it in DSQuery.

Like:





DSQuery User "OU=ACCOUNTS,OU=TRAINEES,DC=TRAINING,DC=LOCAL" |DSMod user -company MyCompanyName

Open in new window

farhankazi

I did use dsquery user "ou=...

Look at my question again