This article outlines the steps to retrieve a list of servers within your domain.
Active Directory (AD) environments often require administrators to pinpoint all servers within a domain. This information is essential for effective management, troubleshooting, and auditing. In this article, we’ll explore different ways to gather a list of servers in an Active Directory domain using built-in tools and PowerShell scripts.
Gaining insight into the servers within your domain is essential for
For those who like a visual approach, the GUI method is the simplest for administrators.
PowerShell is a quick and flexible way to get a list of all servers.
List All Computers in the Domain:
Get-ADComputer -Filter {OperatingSystem -like "*Server*"} -Property Name, OperatingSystem | Select-Object Name, OperatingSystemThis command fetches all servers in the domain by filtering for computers with operating systems that include "Server".
List Only Domain Controllers:
Get-ADDomainController -Filter * | Select-Object HostName, Site
This command gives you a list of all Domain Controllers, along with 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" -NoTypeInformationThis saves the server list to a CSV file for further analysis.
To get a List of Domain Controllers, you can use the following command:
nltest /dclist:<YourDomainName>
Just swap out <YourDomainName> with the name of your domain, and you’ll see all the Domain Controllers listed.
If you want to List All Computers in the Domain, try this command:
dsquery computer -o rdn
This will show you all the computers in the domain, including servers.
This handy tool gives you detailed insights into the servers within your domain and their roles.
Keeping track of servers in an Active Directory domain is crucial for smooth IT management. By using tools like PowerShell scripts, AD utilities and command-line commands, you can easily list all servers and keep your inventory current. Regularly checking this list helps ensure a secure and well-organized domain environment.
No, you need appropriate permissions to query Active Directory for server information.
Perform audits quarterly or during significant infrastructure changes.
Yes, modify the PowerShell command with the `SearchBase` parameter to target specific OUs: Get-ADComputer -SearchBase "OU=Servers,DC=example,DC=com" -Filter * -Property Name, OperatingSystem
Use PowerShell to query specific roles, such as DNS: Get-WindowsFeature -ComputerName | Where-Object Installed -eq $true