dsget and dsquery

G

Guest

I am trying to query AD for billing purposes. Basically, we bill remote locations based on the number of users.

I was trying to find an easy way to query AD to do this.

I want a list that displays a list of users in one column and the respective office location in a column right next to it.

I am able to run: dsquery user "ou=Users,dc=abc,dc=com" -limit 300 -o rdn > users.txt ...this creates a file with the list of users.

I am able to run: dsquery user -name * | dsget user -office ....this creates a listing of the office locations for all users (but doesnt list the usernames beside the office locations).

If you put both of these files together, the list of users will correctly match up with appropriate office locations.

I need to write a query statement to query for both and list both side by side in 2 columns. Is this possible? How?
 
J

Jason Robarts [MSFT]

Does the following give what you want?

dsquery user "ou=Users,dc=abc,dc=com" -limit 300 | dsget
user -display -office

Jason
--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm


DMC said:
I am trying to query AD for billing purposes. Basically, we bill remote
locations based on the number of users.
I was trying to find an easy way to query AD to do this.

I want a list that displays a list of users in one column and the
respective office location in a column right next to it.
I am able to run: dsquery user "ou=Users,dc=abc,dc=com" -limit 300 -o
rdn > users.txt ...this creates a file with the list of users.
I am able to run: dsquery user -name * | dsget user -office ....this
creates a listing of the office locations for all users (but doesnt list the
usernames beside the office locations).
If you put both of these files together, the list of users will correctly
match up with appropriate office locations.
I need to write a query statement to query for both and list both side by
side in 2 columns. Is this possible? How?
 
G

Guest

This produces a help screen...no error...I am not sure which part of the syntax it is not liking...any ideas?
 
J

Jason Robarts [MSFT]

I've double checked on my internal ou and am getting the results I'd expect.

dsquery user "OU=Users,OU=obfuscated,DC=contoso,DC=com" -limit 300 | dsget
user -display -office

all on one line worked. I'd suggest running the dsquery command without
piping it to dsget and verify you are getting a list of DNs from the
specified OU. Then add the pipe to dsget. If the first one works and the
second fails double check the dsget.

Jason
--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm


DMC said:
This produces a help screen...no error...I am not sure which part of the
syntax it is not liking...any ideas?
 
G

Guest

Thank you very much. It worked. I think I might have copied and pasted and there may have been an extra space. I typed it by hand and everything is working now.

Once again, Thanks!
D.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top