?
Solved

List all servers in Active Directory

Posted on 2010-11-23
11
Medium Priority
?
2,128 Views
Last Modified: 2012-05-10
Need a script to list all servers in Active Directory.  From Windows 2000 Server all the way up to and including Windows Server 2008 R2.  Need to make sure all Editions are included.  e.g. Advanced, Standard, Enterprise, Datacenter and 32-bit and 64-bit versions.

Thanks
0
Comment
Question by:Carl Webster
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 2
11 Comments
 
LVL 27

Accepted Solution

by:
KenMcF earned 1336 total points
ID: 34198621
You can use the quest AD cmdlets

get-qadcomputer | where{$_.operatingsystem -match "Server"} | select name, operatingsystem | export-csv c:\server.csv

or if they are all in the same OU

get-qadcomputer -searchroot "OU=Servers,DC=Domain,DC=Local"


depending on what information you may need to do a wmi query.

$servers = get-qadcomputer -searchroot "OU=Servers,DC=Domain,DC=Local"
Foreach ($Server in $servers){
gwmi -computer $server -class win32_operatingsystem | select name, producttype
}
0
 
LVL 37

Author Comment

by:Carl Webster
ID: 34198707
My problem is I do not know if PS is installed on any server or if I will be allowed to install PS.

I just emailed the customer to find out.  It would be nice if PS is installed or they give me permission to install it.

All I need is the "cn" attribute (according to the test dsquery I ran) which should be the server's hostname.
0
 
LVL 27

Assisted Solution

by:KenMcF
KenMcF earned 1336 total points
ID: 34198748
if you just need to CN you can install powershell on a workstation that is a member of the domain.

depending on the number of servers you may need to use the -sizelimit switch

get-qadcomputer -sizelimit 0 | where{$_.operatingsystem -match "Server"} | select DN
0
Office 365 Training for Admins - 7 Day Trial

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

 
LVL 42

Assisted Solution

by:Adam Brown
Adam Brown earned 664 total points
ID: 34198751
This will do pretty much the same thing but utilizes the built in AD Powershell Console for 2008 R2 if you have a DC that uses that.
get-adcomputer -filter * -properties operatingsystem | where
{$_.operatingsystem -match "Server"} | select name, operatingsystem > c:\servers.csv

Open in new window

0
 
LVL 27

Expert Comment

by:KenMcF
ID: 34198752
That should be

get-qadcomputer -sizelimit 0 | where{$_.operatingsystem -match "Server"} | select name
0
 
LVL 42

Expert Comment

by:Adam Brown
ID: 34198759
"My problem is I do not know if PS is installed on any server or if I will be allowed to install PS."
Check if you have a Windows 2008 R2 Domain Controller. If you do, you have the MS AD Powershell Console already.
0
 
LVL 37

Author Comment

by:Carl Webster
ID: 34198777
KenMcF, where do I get and how to I install the Quest AD cmdlets?

I have two other questions I posted this morning.  This file of server names will be used by another script to list all local groups on each server and the members of each group including nested groups.
0
 
LVL 27

Expert Comment

by:KenMcF
ID: 34198784
0
 
LVL 37

Author Comment

by:Carl Webster
ID: 34198826
acbrown2010, when I test this on my lab 2008 R2 DC, I get an error saying the term get-adcomputer is not recognized yada yada yada.
0
 
LVL 37

Author Comment

by:Carl Webster
ID: 34198918
acbrown2010, sorry didn't realize I had to do this:

When the Active Directory module is installed, to start it click Start, point to Administrative Tools, and then click Active Directory PowerShell
0
 
LVL 37

Author Comment

by:Carl Webster
ID: 34235352
I wound up just using ADFind to do this since the AD and all DCs were 2000.

0

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In the absence of a fully-fledged GPO Management product like AGPM, the script in this article will provide you with a simple way to watch the domain (or a select OU) for GPOs changes and automatically take backups when policies are added, removed o…
A bad practice commonly found during an account life cycle is to set its password to an initial, insecure password. The Password Reset Tool was developed to make the password reset process easier and more secure.
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…
Suggested Courses

765 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