How to Get all servers in a domain

Last updated on:

Active Directory stores a computer object for every domain-joined machine, including servers. Each object carries the operating system name and version in the OperatingSystem and it's attributes. Querying those attributes is the standard way to enumerate servers across the domain without relying on network scans or manually maintained inventories.

With ADManager Plus, administrators can not only get all servers in a domain but also manage all the domain-joined computers from a centralized interface, making it easier to maintain an inventory of servers across the domain.

This article covers every method for listing all servers in an Active Directory domain: using PowerShell, the command line, Active Directory Users and Computers (ADUC), Active Directory Administrative Center (ADAC), and ManageEngine ADManager Plus for centralized server management.

  • PowerShell
  • ADUC
  • ADAC
  • Command line
  • ADManager Plus
  • FAQs
 

Prerequisites

Before running the queries below, ensure the Active Directory module is installed through RSAT on Windows 10/11 or enabled through Server Manager on Windows Server. Then run Import-Module ActiveDirectory

Method 1: PowerShell

Get all servers in a domain using PowerShell

The Get-ADComputer cmdlet queries Active Directory for computer objects. Filtering on the OperatingSystem attribute for the string "server" returns only server operating systems, excluding workstations and other devices.

Run the following command to list all enabled servers in the domain:

Get-ADComputer -Filter {(OperatingSystem -like "*Server*") -and (Enabled -eq $true)} ` -Properties Name, OperatingSystem, OperatingSystemVersion, IPv4Address | Sort-Object OperatingSystem | Select-Object Name, OperatingSystem, OperatingSystemVersion, IPv4Address

This retrieves all enabled computer objects whose operating system name contains "Server", sorts the results by OS name, and displays the computer name, OS, OS version, and IP address.

Export the server list to CSV

To save the results to a CSV file for reporting or offline review:

Get-ADComputer -Filter {(OperatingSystem -like "*Server*") -and (Enabled -eq $true)} ` -Properties Name, OperatingSystem, OperatingSystemVersion, IPv4Address | Sort-Object OperatingSystem | Select-Object Name, OperatingSystem, OperatingSystemVersion, IPv4Address | Export-Csv -Path .\DomainServers.csv -NoTypeInformation

This runs the same query and pipes the output to a CSV file named DomainServers.csv in the current directory. Open it in Excel or import it into a reporting tool.

Filter by a specific Windows Server version

To list only servers running a specific version, narrow the filter using the OperatingSystemVersion attribute or a more specific OS name string:

To list only Windows Server 2019 machines

Get-ADComputer -Filter {OperatingSystem -like "*Server 2019*"} ` -Properties Name, OperatingSystem, OperatingSystemVersion, IPv4Address | Select-Object Name, OperatingSystem, OperatingSystemVersion, IPv4Address

Replace "Server 2019" with the version string that matches your environment, such as "Server 2016", "Server 2022", or "Server 2012 R2".

List servers in a specific OU

Use the -SearchBase parameter to restrict the query to a specific organizational unit:

Get-ADComputer -Filter {OperatingSystem -like "*Server*"} ` -SearchBase "OU=Servers,DC=contoso,DC=com" ` -Properties Name, OperatingSystem, OperatingSystemVersion, IPv4Address | Select-Object Name, OperatingSystem, OperatingSystemVersion, IPv4Address

Replace the -SearchBase value with the distinguished name of your target OU. This is useful in large environments where servers are organized into dedicated OUs.

Count servers by operating system version

To get a quick breakdown of how many servers of each OS version are in the domain:

Get-ADComputer -Filter {OperatingSystem -like "*Server*"} ` -Properties OperatingSystem | Group-Object OperatingSystem | Sort-Object Count -Descending | Select-Object Name, Count

This groups all server computer objects by their operating system name and returns a count for each version, sorted from most to least common.

Supported parameters

The following essential parameters can be used while retrieving server information from Active Directory:

Parameter Description
-Filter Specifies the query used to find computer objects based on conditions such as operating system and account status.
-SearchBase Limits the search to a specific Active Directory organizational unit (OU) or container.
-Properties Specifies additional Active Directory attributes to retrieve, such as OperatingSystem, OperatingSystemVersion, and IPv4Address.
-Server Specifies the Active Directory Domain Services instance or domain controller to query.
-Path Specifies the location and filename where the server list is exported when using Export-Csv.
-NoTypeInformation Prevents PowerShell from adding type information to the exported CSV file.

Method 2: Active Directory Users and Computers (ADUC)

How to list all servers in a domain using ADUC

Active Directory Users and Computers(ADUC) does not provide a dedicated server filter, but you can use its search and filter capabilities to locate server computer objects manually.

  1. Open Active Directory Users and Computers (dsa.msc).
  2. Right-click the domain node or a specific OU and select Find.
  3. In the Find Users, Contacts, and Groups dialog, change the object type to Computers using the Find dropdown.
  4. Select the Advanced tab.
  5. In the Field dropdown, select Computer > Operating System. Set the Condition to Starts with and the Value to Windows Server.
  6. Click Find Now. ADUC returns all computer objects whose operating system starts with "Windows Server" within the selected scope.

Results can be sorted by clicking column headers. To view additional attributes such as OS version or IP address, right-click a column header and select which columns to display.

Method 3: Active Directory Administrative Center (ADAC)

How to find servers in a domain using ADAC

Active Directory Administrative Center (ADAC) provides a global search with attribute-level filtering that is more flexible than ADUC's Find dialog.

  1. Open Active Directory Administrative Center (dsac.exe).
  2. In the left pane, select your domain.
  3. Click the search icon at the top of the center pane to open the global search bar.
  4. Select Convert to LDAP query from the search type dropdown.
  5. Enter the following LDAP filter to return all server computer objects:
    (&(objectCategory=computer)(operatingSystem=*Server*))
  6. Press Enter or click the search icon. ADAC returns all matching computer objects.
  7. Click a column header to sort results. Right-click column headers to add OperatingSystem or OperatingSystemVersion to the view.

Method 4: The command line

How to list servers in a domain using the command line

The command line does not have a dedicated tool equivalent to Get-ADComputer for listing servers by operating system. However, two approaches are available depending on what you need.

To list all computer objects in the domain using dsquery:

dsquery computer -limit 0

This returns the distinguished names of all computer objects in the domain. It does not filter by operating system, so the output includes workstations and other devices alongside servers.

To narrow results to objects in a specific OU:

dsquery computer "OU=Servers,DC=contoso,DC=com" -limit 0

This restricts the query to the specified OU. Replace the distinguished name with your target path.

To retrieve the operating system attribute for a specific computer using dsget:

dsquery computer -name SERVERNAME | dsget computer -dn -desc

Note: dsquery and dsget can confirm a machine exists in AD and retrieve basic attributes, but they do not support filtering by operating system across the whole domain the way PowerShell does. For a filtered server list, PowerShell is the correct tool.

Limitations:

Native Windows tools can locate server computer objects in Active Directory, but they have limitations when it comes to inventory management and reporting at scale.

Limited filtering capabilities.dsquery computer returns computer objects without providing an operating system filter, while ADUC and ADAC require additional configuration to filter by the OperatingSystem attribute. ADUC requires the Advanced tab, and ADAC requires administrators to use LDAP syntax for OS-based filtering.

No direct export or centralized reporting. ADUC and ADAC do not provide built-in options to export search results to CSV, Excel, or other structured formats. PowerShell can export results, but administrators must create and maintain scripts to generate the required reports.

No scheduling or automated report delivery. ADUC, ADAC, and dsquery are primarily on-demand tools. PowerShell scripts can be scheduled separately, but native tools do not provide built-in scheduling, recurring report generation, or automated email delivery.

Server inventory may be incomplete or inaccurate. The OperatingSystem attribute can be blank or outdated, particularly for manually created or older computer objects. Decommissioned servers may also remain in Active Directory, requiring administrators to use last logon information or other checks to identify stale objects. Additionally, the IPv4Address value returned by Get-ADComputer is resolved through DNS at query time and may not reflect the server's current IP address if DNS records are outdated.

Requires technical expertise and additional configuration. PowerShell-based reporting requires the Active Directory module, which may require RSAT installation on workstations. Advanced ADUC/ADAC filtering can also require knowledge of AD attributes or LDAP syntax. Providing narrowly scoped access to non-administrators may require additional Active Directory delegation.

No consolidated multi-domain reporting. Native tools do not provide a single interface for server inventory across multiple domains. Administrators typically need to query each domain separately and consolidate the results manually.

Method 5: ADManager Plus

ADManager Plus provides a built-in OS-based computer report that lists all servers in the domain without PowerShell scripting or LDAP queries. The report reads the OperatingSystem and OperatingSystemVersion attributes directly from Active Directory and presents results in a filterable, sortable, exportable table.

Generate the OS-based computer report

  1. Log in to ADManager Plus.
  2. Navigate to Reports > Computer Reports > OS Based Reports.
  3. Select the target domain from the Domain drop-down.
  4. Select the domain to generate a report of all servers in the domain, or select a specific OU to list servers only within that OU.
  5. Select the specific server from the Select OS: drop down, or leave it unfiltered to see all operating systems.
  6. Click Generate. The report displays all matching computer objects with their OS name, OS version, and other attributes.
  7. Click Export and choose CSV, PDF, XLS, or XLSX.
  8. To schedule the report for recurring delivery, click Schedule, set the frequency and recipients, and click Save.

Schedule and email the report automatically

  1. Generate the report, then click Schedule.
  2. Click Create New Schedule, Give the schedule a name
  3. Select Computer Reports, followed by OS Based Report
  4. Set the frequency (daily, weekly, or monthly), delivery time, and output format.
  5. Enter one or more recipient email addresses.
  6. Click Save. ADManager Plus sends the report at each scheduled interval without further intervention.

How ADManager Plus simplifies server inventory management

Managing server inventory across Active Directory using PowerShell scripts and native tools requires scripting knowledge, manual execution, and ongoing maintenance. ADManager Plus provides pre-built computer reports that remove the need for scripting on common inventory tasks. Using ADManager Plus, you can:

Frequently asked questions

Run Get-ADComputer -Filter * -Properties Name, OperatingSystem, LastLogonDate in PowerShell to return every computer object in the domain, not just servers. Add -SearchBase to scope it to a specific OU. Without PowerShell, dsquery computer -limit 0 returns all computer objects by distinguished name, though with fewer filtering options. You can also get a list of all computers in Active Directory using ADManager Plus' Computer Reports without writing scripts.

Add the -SearchBase parameter to Get-ADComputer with the distinguished name of the target OU. For example: -SearchBase "OU=Servers,DC=contoso,DC=com". This restricts the query to that OU and its child containers.

Pipe the Get-ADComputer output to Export-Csv -Path .\DomainServers.csv -NoTypeInformation. The Export to CSV section in Method 1 contains the complete command. Alternatively, ADManager Plus lets you export the server list to CSV and multiple other formats and schedule reports to be sent to your desired recipients without using PowerShell scripts.

Use the Group Policy module: Get-GPO -All | Select-Object DisplayName, GPOStatus, ModificationTime. This requires the GroupPolicy PowerShell module (installed with RSAT or on a domain controller). You can also view all GPOs through the Group Policy Management Console (GPMC) by expanding the "Group Policy Objects" container for the domain. You can also use ADManager Plus' GPO Reports to get the complete list of GPOs and manage them without writing scripts.

Remove the -Enabled $true condition from the filter, or replace it with -Enabled $false to see only disabled objects. By default, the examples above list enabled computers to exclude decommissioned machines. Alternatively, you can use ADManager Plus' Computer Reports to fetch the disabled servers.

Service Principal Names (SPNs) can be listed with the built-in setspn -Q */* command from an elevated command prompt, or in PowerShell using Get-ADUser/Get-ADComputer with the -Properties ServicePrincipalName flag. This returns all objects in the domain that have one or more SPNs registered, which is useful for finding Kerberos delegation issues or duplicate SPNs.

Simplify Active Directory server reporting with ADManager Plus

The one-stop solution to Active Directory Management and Reporting
Email Download Link Email the ADManager Plus download link