Reading Time: < 1 minute

If you are looking for a quick way of exporting an inventory of all the Windows Servers that reside within an AD environment, look no further!

PowerShell to the rescue!

Requirements for using PowerShell AD Module related cmdlets:

  • Windows 7 and onward with RSAT Tools Installed
  • Windows Server 2008 R2 and onward with RSAT Tools Installed or AD Domain Services Installed with its Management Tools

The following One-Liner will return a list of all the Computer objects running Windows Server OS within an AD environment. 

Get-ADComputer -Filter {OperatingSystem -like "*windows*server*"} -Properties * | sort DNSHostname | ft DNSHostName, OperatingSystem -Wrap -Auto

In case you need to export the resulted inventory to a file you just need to alter a bit the one-liner.

Get-ADComputer -Filter {OperatingSystem -like "*windows*server*"} -Properties * | sort DNSHostname | select DNSHostName, OperatingSystem | Export-Csv -Path "$home\Desktop\ADServers.csv"

Thanks for reading my blog!

Feel free to drop your comment or question below.