Solved

DSQUERY help required

Posted on 2008-10-24
9
950 Views
Last Modified: 2012-05-05
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
0
Comment
Question by:bsharath
  • 5
  • 4
9 Comments
 
LVL 35

Expert Comment

by:Joseph Daly
ID: 22799049
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.
0
 
LVL 35

Expert Comment

by:Joseph Daly
ID: 22799119
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
0
 
LVL 11

Author Comment

by:bsharath
ID: 22819029
Can i have the more specific command on this. I get invalid command error.
0
 
LVL 11

Author Comment

by:bsharath
ID: 22819030
Can i have the more specific command on this. I get invalid command error.
0
Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

 
LVL 35

Expert Comment

by:Joseph Daly
ID: 22819047
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.
0
 
LVL 11

Author Comment

by:bsharath
ID: 22819058
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.
0
 
LVL 11

Author Comment

by:bsharath
ID: 22819059
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.
0
 
LVL 35

Accepted Solution

by:
Joseph Daly earned 500 total points
ID: 22821436
Ok so this is what I did this morning and it cmae out with the results I expected.

DSQUERY * "{start node path DC=blah DC=blah etc}" -filter "(&(&(&(|(&(objectCategory=person)(objectSid=*)(!samAccountType:1.2.840.113556.1.4.804:=3))(&(objectCategory=person)(!objectSid=*))(&(objectCategory=group)(groupType:1.2.840.113556.1.4.804:=14))))(objectCategory=user)(!manager=*)))"
0
 
LVL 11

Author Comment

by:bsharath
ID: 22838687
Thank U...
0

Featured Post

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Super Scope, DHCP 5 51
copy-item script help 15 66
Password change over a wireless connection using radius 4 24
change the windows script file to BAT 10 29
Find out how to use Active Directory data for email signature management in Microsoft Exchange and Office 365.
Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now