Question Locked

Dsmod -addmbr failure when piping from Dsquery

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

The syntax is: "dsquery user "OU=ouName,DC=companyName,DC=Com" | dsmod group "CN=groupName,OU=ouNmae,DC=companyName,DC=Com" -addmbr"

The error is: "dsmod failed:CN=groupName,OU=ouName,DC=companyName,DC=Com
:The parameter is incorrect.
type dsmod /? for help."

If I run the dsquery portion, it returns a list of DN's. If I take one of those DN's and stick it to the end of the dsmod portion, that user is added successfully. I just can't pipe the two together. Thoughts?

5 replies

by bizzo

The only thing I can think of is that maybe you've done it correctly here in your post, but not when you're doing it for real?

Sorry not to be of much help.

by dumphrey

and compare that to the expected input syntax of dsmod..

[edit]
This seems to work:

dsquery user -name joh* | dsmod group "CN=Testing,CN=Users,DC=domain,DC=local" -addmbr

It finds all users with DN matching joh* and adds them to the Testing group.
I got the group DN from a dsquery group command and sent it to a text file to avoid spelling mistakes...
Looks to pretty much be exactly what you started with.

[EDIT2]
List all users in an OU/container (users container in my example) and add them to the Testing group in the TestOU OU of domaine.local...

DSQUERY USER -startnode CN=Users,DC=domain,DC=local | DSMOD group "CN=Testing,OU=testou,DC=domaine,DC=local" -addmbr

by mhashemi

Doing this: DSQUERY USER -startnode CN=Users,DC=domain,DC=local > c:\test.txt results in a list of DN's such as:"CN=Doe\, John,CN=Users,DC=domain,DC=local"

So I did this: DSMOD group "CN=Testing,OU=testou,DC=domain,DC=local" -addmbr < c:\test.txt which resulted in "dsmod failed:CN=Testing,OU=testou,DC=domain,DC=local
:The parameter is incorrect."

So I opened up the test.txt file and copied out a DN. Doing this: DSMOD group "CN=Testing,OU=testou,DC=domain,DC=local" -addmbr "CN=Doe\, John,CN=Users,DC=domain,DC=local" works great.

What gives?

by mhashemi

The answer is...run it from the DC. The synatx is:

DSQUERY USER -startnode CN=Users,DC=domain,DC=local | DSMOD group "CN=Testing,OU=testou,DC=domain,DC=local" -addmbr

I don't understand though why I can run the individual parts from my machine, but can't run the piped command.

This discussion is closed to new replies.