how to query DC from a member server to get a list of servers located in Active Directory Users and Computers.

I have to write a script to gather a list of all the servers on a domain from a windows 2012 R2 log server so that it can populate a powershell script.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

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.

If you want to list all servers from Active directory you can use the following powershell command.

import-module ActiveDirectory

Get-ADComputer -Filter {OperatingSystem -Like "Windows Server*"} -Property *
If you just need to create a list of computer names, make this modification.  Side note - I never include -Property * outside of testing as it will slow down your query and likely pull a lot of information that you don't need.
Get-ADComputer -Filter {OperatingSystem -Like "Windows Server*"} | Select -expandProperty Name

Open in new window

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
gmckfnAuthor Commented:
Apparently I need the powershell module to allow me to use the get-adcomputer cmdlet    anyone know which one I need to get??  I see over 35 modules and searched through them.
gruppomg mentioned it.  On a workstation you need to have the RSAT tools installed for the module to be available.  If you're running PS 3.0+, then you don't need to explicitly load the module - it will do it automatically if it's available.
gmckfnAuthor Commented:
Thanks guys.... that worked perfectly.    sorry I missed the module import.  I didn't know I had to add the module as a windows feature.
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

From novice to tech pro — start learning today.