Solved

DSQUERY help required

Posted on 2008-10-24
9
953 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 11

Author Comment

by:bsharath
ID: 22819030
Can i have the more specific command on this. I get invalid command error.
0
 
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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Last week, our Skyport webinar on “How to secure your Active Directory” (https://www.experts-exchange.com/videos/5810/Webinar-Is-Your-Active-Directory-as-Secure-as-You-Think.html?cid=Gene_Skyport) provided 218 attendees with a step-by-step guide for…
This article explains the steps required to use the default Photos screensaver to display branding/corporate images
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

860 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