POWERSHELL — List ALL Servers on a Domain and Export to CSV

Use this script if you want to get a list of all servers on the domain and have it export to a CSV file. Remember most powershell reports need to be ran under your admin account for them to work 🙂

Revise the code to your needs!

Import-Module ActiveDirectory
Get-ADComputer -Filter 'operatingsystem -like "*server*" -and enabled -eq "true"' ` -Properties Name,Operatingsystem,OperatingSystemVersion,IPv4Address | Sort-Object -Property Operatingsystem |
Select-Object -Property Name,Operatingsystem,OperatingSystemVersion,IPv4Address| export-csv -path c:\temp\serverexport.csv

In this script, I’m asking for a column under the object’s name, OS, OSVersion, and the IP Address in that specific order. For the path, it can be changed to your C drive, Desktop, or wherever.

My end result looked like this:

Â