Link to home
Start Free TrialLog in
Avatar of bsharath
bsharathFlag for India

asked on

DSQUERY help required

Hi,

This code gets all users who do not have a manager.

DSQuery * -Filter "(&(sAMAccountType=805306368)(!manager=*))" -Attr sAMAccountName -Limit 0 >C:\UsersWithoutManager.txt

Can this be changed to query on a Specific OU rather than the whole domain.

REgards
Sharath
Avatar of Joseph Daly
Joseph Daly
Flag of United States of America image

Yes it can basically you can have the dsquery select only the ou you want it would be something like this.

dsquery ou dc=mydom,dc=com and then your filter expression. You would need to enter the full path to your OU like the mydom.com above.
Great site for all of you dsquery command line needs, also all the other DS commands as well.

http://www.geocities.com/rick_lively/MANUALS/COMMANDS/D/DSQUERY.HTM#ParameterOu
Avatar of bsharath

ASKER

Can i have the more specific command on this. I get invalid command error.
Can i have the more specific command on this. I get invalid command error.
I will grab you some more info on this tomorrow. I dont have easy access to my AD right now. Once im back in the office Ill sort out the query.
I get this

C:\>dsquery "OU=Named Accounts,OU=User Accounts,OU=IN,OU=Cou,DC=ment,DC=Group,DC=co,DC=uk -Filter "(&(sAMAccountType=805306368)(!manager=*)
)" -Attr sAMAccountName -Limit 0 >C:\UsersWithoutManager.txt
(!manager was unexpected at this time.
I get this

C:\>dsquery "OU=Named Accounts,OU=User Accounts,OU=IN,OU=Cou,DC=ment,DC=Group,DC=co,DC=uk -Filter "(&(sAMAccountType=805306368)(!manager=*)
)" -Attr sAMAccountName -Limit 0 >C:\UsersWithoutManager.txt
(!manager was unexpected at this time.
ASKER CERTIFIED SOLUTION
Avatar of Joseph Daly
Joseph Daly
Flag of United States of America 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
Thank U...