In this post, I’ll show you several examples of the Get-ADComputer PowerShell command. This command is used to search active directory to get single or all computer accounts. I’ll also show you how to use the Get-ADComputer filter option to limit results based on specific computer properties (for example, the name, OU, and modified date).
Let’s get started.
Get-ADComputer Examples
1. Get All AD Computers
get-adcomputer -filter *
This command will get a list of all computers in the domain.
2. Get All Computers with all properties
get-adcomputer -filter * -properties *
This command will get all computers and all of the computer properties (attributes). By default, the get-adcomputer command only displays 8 properties. You must use the -properties * command to list them all.
3. Get All Computers from an OU
Get-ADComputer -Filter * -SearchBase "OU=ADPRO Computers,DC=ad,DC=activedirectorypro,DC=com"
This command will get all computers from a specific OU by using the -SearchBase parameter and the distinguishedName of the OU.
4. Get All Computers and Show Specific Properties
Get-ADComputer -Filter * | select name, Enabled
This command will get all computers and limit the output to display the name and enabled properties only.
5. Get All Enabled Computers
Get-ADComputer -Filter "Enabled -eq 'True'"
This command uses the -filter option to limit the results to only enabled computers.
To limit the properties use the select option followed by the properties you want to display.
Get-ADComputer -Filter "Enabled -eq 'True'" | select Name, Enabled
6. Get All Disabled Computers
Get-ADComputer -Filter "Enabled -eq 'false'" | select Name, Enabled
This command filters for enabled computers and limits the output to the name and enabled properties.
7. Get All Computers with a specific Name (Wildcard Search)
Get-ADComputer -Filter "Name -like 'SRV*'" | select Name, Enabled
This command searches for computers that start with srv in the name field.
8. Get All Computers and IP Addresses
Get-ADComputer -Filter * -properties * | select Name, Enabled,ipv4address
This command gets all computers and displays the IP address of each computer.
9. Get All Computers lastlogondate
Get-ADComputer -Filter * -properties * | select name,lastlogondate
This command gets all domain computers and displays the lastlogondate value.
10. Get All Computers Last Modified Date from an OU
Get-ADComputer -Filter * -SearchBase "OU=ADPRO Computers,DC=ad,DC=activedirectorypro,DC=com" -properties *| select name, whenchanged
This command will get all computers from a specific OU and display the computer’s last modified date (whenchanged attribute).
I hope you found this article useful. If you have questions or comments please post them below. Refer to the Microsoft documentation to view the complete get-aduser syntax.
Built-in Active Directory Computer Reports
The AD Pro Toolkit includes over 200 built-in Active Directory Reports for users, computers, groups, GPOs, and security. Very easy to use and a simple alternative to creating PowerShell scripts.
Thanks a lot for the tips! included the one in commentaries. They are very useful!
Hi, Sergei.
You are welcome.
PS C:\Windows\system32> get-adcomputer -filter *
get-adcomputer : The term ‘get-adcomputer’ is not recognized as the name of a cmdlet, function, script file, or
operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try
again.
At line:1 char:1
+ get-adcomputer -filter *
+ ~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (get-adcomputer:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
get-adcomputer requires the PowerShell Active Directory module? Do you have the RSAT tools installed?
This works in small environments in large environments running Get-Adcomputer -filter * and -Properties * will fall over.
In large environments I would not use -properties *, instead list only the properties you need.
get-adcomputer -filter * -Properties name, enabled | select name, enabled