Home » Windows Servers » Windows 2008R2 » Export a list of all your Windows Server Systems in an AD Environment using Powershell

Export a list of all your Windows Server Systems in an AD Environment using Powershell

a quick way of exporting an inventory of all the Windows Servers that reside within an AD environment.

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 "windowsserver*"} -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 "windowsserver*"} -Properties * | sort DNSHostname | select DNSHostName, OperatingSystem | Export-Csv -Path "$home\Desktop\ADServers.csv"