PowerShell: List AD Computers By OS

The below PowerShell code will get the ComputerName, Description, and list by Operating System. Two output methods are available, on screen and export to CSV file.

Replace the asterisk (*) with the Operating Systems name, however run it with the * to return all OS’s.

 

Display on Screen:
Get-ADComputer -Filter { OperatingSystem -Like '*' } -Properties OperatingSystem, Description | Select Name, OperatingSystem, Description | Format-Table -AutoSize
Export to CSV:
Get-ADComputer -Filter { OperatingSystem -Like '*' } -Properties OperatingSystem, Description | Select Name, OperatingSystem, Description | Export-CSV -Path C:\Windows\Temp\Computers.csv

Leave a Reply