Solved

DSquery - AD query in windows 2k3 and 2k8

Posted on 2010-09-12
9
767 Views
Last Modified: 2012-05-10


Hi All
I am wondering if anyone came cross this and can help,

Normally if I was to do search for server in windows 2003 AD, let’s say server called serverA, I can do normal search in AD (GUI) but it does not show the exact location of the server i.e. it shows that server exist in AD but not exact location i.e. in which OU is server located. If I have let’s say 100 of OUs or more then it is REALLY hard work trying to go through every OU and do search!!

I need this for windows 2003 and 2008, I have not experimented with windows 2008 R2 and I am hoping it does have feature in it that makes it easy i.e. I mean MS have addressed this issue and made it easy in windows 2008 and windows 2008R2

I am aware of dsquery command.

Thanks for your time and effort
0
Comment
Question by:linuxhunts
  • 6
  • 3
9 Comments
 
LVL 39

Accepted Solution

by:
Krzysztof Pytko earned 250 total points
ID: 33659766
Open your Active Directory Users and Computers console (dsa.msc), click right mouse button on your FQDN and choose "Find". In "Find" dropdown box, select "Computers" and type server name which you want to find. Then in windows menu choose "View -> Select Columns" and add "Published in". In this columns you will see full path where the object exists.

Hope it helps
0
 

Author Comment

by:linuxhunts
ID: 33660067

Hi iSiek

You are gun!! it was so simple yet so sweet, however before i close this and reward you full points, can you please tell me how i can copy and paste the location of the servers in AD i.e. i have been asked to write down the exact location of at leaset 500 servers with no spelling mistakes or missing under line etc as part of project.

However when i look at the location of some server as you indicated in your answer, oh my God it is so long and i am sure i will be making typo errors. When i right click i cannot copy the location!!

is there way i can copy and paste the location in notepad or winword etc

many Thanks
0
 
LVL 39

Expert Comment

by:Krzysztof Pytko
ID: 33660122
yes it is possible, but unfortunatelly use have to use DSQUERY command :)

First of all, prepare text file with all those names (one name per line) and save it as servers.txt

Now, preapre bat or cmd file

@echo off
for /f %%i in (servers.txt) dsquery computer -name %%i | dsget computer -samid -dn >c:\list_ou.txt

Log on to server or machine with administrative tools installed and run in command-line that batch file. Then on C-Drive you should see the results.

You can import them into Excel and prepare for better look :]
0
 
LVL 39

Expert Comment

by:Krzysztof Pytko
ID: 33660242
you can also use "Custom search" in Active Directory Users and Computers console in "Advance" tab place this code

(objectCategory=Computer)(objectClass=Computer)(operatingSystem=*Server*)

and you can export list but without location :/
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 39

Expert Comment

by:Krzysztof Pytko
ID: 33660993
I think I have a better solution for you :)
Download ADFIND from http://www.joeware.net/freetools/tools/adfind/index.htm
and extract it let's say c:\ADFIND and from command-line type

c:\
cd adfind
c:\>ADFIND\adfind -default -f "&(objectCategory=Computer)(objectClass=Computer)(operatingSystem=*Server*)" samaccountname -csv -tdca > c:\Servers.csv

above command is a single line!

It exports all servers into CSV file.
0
 
LVL 39

Expert Comment

by:Krzysztof Pytko
ID: 33661003
you don't have to use -tdca switch
0
 

Author Comment

by:linuxhunts
ID: 33687495

Hi iSiek

thanks for your time and effort, i managed to find the answer i was looking for and here i am sharing it with everyone just in case in future someone needs it. It is really as simply as your first answer but with ability to copy and paste the location

-In AD go to view and enable advance features
- Do search in AD under FQDN as per usual, once server you looking for appears,
-Right click on server and go properties
-In properties box you will see OBJECT TAB - click on it and oops it is there

Welll have to admit Microsoft did think well it is me who was not thinking :>)

Anyway iSiek i will reward you the points for your answer one and extra effort and time

many thanks again
0
 

Author Closing Comment

by:linuxhunts
ID: 33687547

The Solution i was looking for is the one i wrote in my last comments
0
 
LVL 39

Expert Comment

by:Krzysztof Pytko
ID: 33688679
Thank you :) I was thinking about automated solution :] But thanks for remark :)
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Join & Write a Comment

I have put this article together as i needed to get all the information that might be available already into one general document that could be referenced once without searching the Internet for the different pieces. I have had a few issues where…
The recent Microsoft changes on update philosophy for Windows pre-10 and their impact on existing WSUS implementations.
This tutorial will walk an individual through configuring a drive on a Windows Server 2008 to perform shadow copies in order to quickly recover deleted files and folders. Click on Start and then select Computer to view the available drives on the se…
This tutorial will show how to configure a new Backup Exec 2012 server and move an existing database to that server with the use of the BEUtility. Install Backup Exec 2012 on the new server and apply all of the latest hotfixes and service packs. The…

747 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

18 Experts available now in Live!

Get 1:1 Help Now