How to Get a List of Servers in a Domain

In this Guide:

Active Directory (AD) environments often require administrators to identify all servers within a domain. This information is crucial for effective management, troubleshooting, and auditing. In this article, we’ll cover various methods to retrieve a list of servers in an Active Directory domain using built-in tools and PowerShell scripts.


Why List Servers in a Domain?

Understanding the servers in your domain is critical for:

  • Inventory Management: Keeping track of all Active Directory servers.
  • Troubleshooting Issues: Identifying servers hosting critical roles like Domain Controller (DC), DNS, or file sharing.
  • Security Audits: Ensuring all servers comply with organizational policies.

Methods to List All Servers in an Active Directory Domain

1. Using Active Directory Users and Computers (GUI)

The GUI method is the easiest for administrators who prefer a visual approach.

  1. Open Active Directory Users and Computers (ADUC):
    • Press Win + R, type dsa.msc, and hit Enter.
  2. Navigate to the Computers or Domain Controllers organizational unit (OU).
  3. View the list of servers in the selected OU.
    • Use the Find feature to search for specific server types.

2. Using PowerShell

PowerShell provides a quick and flexible way to retrieve a list of all servers.

Prerequisites:

  • Ensure the Active Directory module is installed (Install-WindowsFeature RSAT-AD-PowerShell).
  • Run PowerShell as an administrator.

Commands to List Servers:

  • List All Computers in the Domain:

    Get-ADComputer -Filter {OperatingSystem -like "*Server*"} -Property Name, OperatingSystem | Select-Object Name, OperatingSystem
    

    This command retrieves all servers in the domain by filtering computers with operating systems containing "Server".

  • List Only Domain Controllers:

    Get-ADDomainController -Filter * | Select-Object HostName, Site
    

    This command lists all Domain Controllers, including their hostnames and sites.

  • Export the Server List to a CSV File:

    Get-ADComputer -Filter {OperatingSystem -like "*Server*"} -Property Name, OperatingSystem | Select-Object Name, OperatingSystem | Export-Csv -Path "C:\\ServerList.csv" -NoTypeInformation
    

    Save the server list to a CSV file for further analysis.

3. Using Command Prompt (Net Commands)

  • Retrieve a List of Domain Controllers:

    nltest /dclist:<YourDomainName>
    

    Replace <YourDomainName> with your domain’s name to list all Domain Controllers.

  • List All Computers in the Domain:

    dsquery computer -o rdn
    

    This command lists all computers, including servers, in the domain.

4. Using Active Directory Sites and Services

This tool provides detailed information about the servers in the domain and their associated roles.

  1. Open Active Directory Sites and Services:
    • Press Win + R, type dssite.msc, and hit Enter.
  2. Expand Sites to view all servers, including Domain Controllers and Global Catalog servers, grouped by site.

Best Practices for Managing Domain Server Lists

  1. Regular Auditing: Periodically review the list to identify unauthorized or outdated servers.
  2. Maintain Documentation: Keep an updated inventory of all servers, their roles, and locations.
  3. Automate Reports: Schedule PowerShell scripts to generate and email server lists periodically.
  4. Implement Access Controls: Limit who can access server information to prevent misuse.

Conclusion

Tracking servers in an Active Directory domain is essential for efficient IT administration. Using methods like PowerShell scripts, AD tools, and command-line utilities, you can easily list all servers and maintain an updated inventory. Regularly reviewing this list ensures a secure and well-managed domain environment.

Frequently asked questions: