POWERSHELL GET AD COMPUTER OBJECT LIST OUTPUT TO FILE
Check out these PowerShell one-liner examples below, you can change and test the filter part of it to suit your needs for what you're querying from the AD Operating System
, etc. attributes.
Be sure to change the output text file name and location where you need it to be output to in the Out-File C:\Test\Test.txt
part file location wise.
Use for non-Servers List
Get-ADComputer -Filter {OperatingSystem -NotLike "*Server*"} | Select -Expand Name | Out-File C:\Test\Test.txt
Use for Servers List
Get-ADComputer -Filter {OperatingSystem -Like "*Server*"} | Select -Expand Name | Out-File C:\Test\TestServers.txt
Use for Custom Description List
(You can select all the AD computer objects from AD Users and Computers
in the specific OU, then right-click
and select Properties
while ALL COMPUTER OBJECTS are selected, and then add a custom and unique string related to the OU for the Description
value (see below screen shot). You could then refine the search filter below to look for the AD computers with this custom Description
unique value to each OU)
Get-ADComputer -Filter {Description -Like "*CustomTestString*"} | Select -Expand Name | Out-File C:\Test\Custom.txt