Computer account location in Active directory

We have a pretty big AD and have lots of OU by department and locations. if i search for a user or computer in the find window It does not tell me in what ou is located, I know there is a way to do seach AD and get the full dn path but its not working for me, does anyone know of  a command that can tell me where an ad object is located in AD.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

use dsquery computer dc="your domain", dc="local,net,com,etc"  will give you all comoputers and ou

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It will tell you the DN when you double-click the machine in the Search results, and then check the Object tab.
10 Tips to Protect Your Business from Ransomware

Did you know that ransomware is the most widespread, destructive malware in the world today? It accounts for 39% of all security breaches, with ransomware gangsters projected to make $11.5B in profits from online extortion by 2019.

als to find just one computer at the end of my last post use -name d* will give you all computers that start with d

so an example is

dsquery computer dc=microsoft,dc=com -name n*
Even easier:

Pull up AD users and Computers
Right click on the domain and select Find
Search for any object you want.
Once it finds your object, click VIEW on the top of the Find box.
Select Choose Columns
On the left side,  scroll down and select "Published At"

Then save your console so it keeps this view.

From now on you will have the location returned in your search.
quippeeAuthor Commented:
Great Comments, I will try to spread the points :)
quippee, just for reference i usually use the command line or power shell to admin.  The reason is that once you become familiar with the command line you can always easily script them.

If you rely on the GUI, you become accustomed to that view and it is hard to go back to command line.

just my thoughts.

quippeeAuthor Commented:
thats true, but for some reason it didnt work with users

dsquery computer dc=domain,dc=net -name pc01


dsquery user dc=domain,dc=net -name jcarrie

just gave a blank line
That depends on whether "jcarrie" is actually the name of the user object in AD, or the user name (and since you're searching from the domain root anyway, you can just leave out the domain name, or replace it with domainroot, which is easier to type ...).
Anyway try
dsquery user "dc=domain,dc=net" -samid jcarrie
this microsoft link give many examples of dsquery and is worth taking a loook at
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Server 2003

From novice to tech pro — start learning today.