Solved

DSQUERY help required

Posted on 2008-10-24
9
949 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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I know all systems administrator at some time or another has had to create a script to copy file from a server share to a desktop. Well now there is an easy way to do this in Group Policy. Using Group policy preferences is not hard. The first thing …
Do you have users whose passwords are expiring and they are constantly calling you?  Well I sure did and needed a way to put an end to this.  We have a lot of remote users which would not be notified that their passwords were expiring since they wer…
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 and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

757 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

21 Experts available now in Live!

Get 1:1 Help Now