How to Get AD Computer Information Using PowerShell
Use the
Get-ADComputer cmdlet in PowerShell to retrieve Active Directory computer objects. You can specify filters and properties to get detailed information about computers in your domain.Syntax
The basic syntax of Get-ADComputer is:
Get-ADComputer -Filter <filter> -Properties <properties>-Filterdefines which computers to get (e.g., all or specific names).-Propertiesspecifies extra details to retrieve beyond the default.
powershell
Get-ADComputer -Filter <Filter> [-Properties <Property1>,<Property2>,...]
Example
This example gets all computers in Active Directory and shows their names and operating system details.
powershell
Get-ADComputer -Filter * -Properties OperatingSystem | Select-Object Name, OperatingSystem
Output
Name OperatingSystem
---- ---------------
COMPUTER01 Windows 10 Pro
COMPUTER02 Windows Server 2019
COMPUTER03 Windows 11 Enterprise
Common Pitfalls
Common mistakes include:
- Not running PowerShell as a user with permission to query Active Directory.
- Using
-Filterincorrectly, such as passing a string without quotes or invalid syntax. - Expecting all properties by default; you must specify extra properties with
-Properties.
powershell
## Wrong: Missing quotes around filter string Get-ADComputer -Filter Name -eq 'COMPUTER01' ## Right: Correct filter syntax Get-ADComputer -Filter "Name -eq 'COMPUTER01'"
Quick Reference
Summary tips for Get-ADComputer:
- -Filter: Use
*for all computers or a valid filter string. - -Properties: Add properties like
OperatingSystem,LastLogonDate. - Select-Object: Use to display only needed fields.
- Run PowerShell with Active Directory module loaded and proper permissions.
Key Takeaways
Use Get-ADComputer with -Filter to specify which computers to retrieve.
Add -Properties to get extra details beyond default fields.
Always run PowerShell with Active Directory module and proper permissions.
Use Select-Object to show only the information you need.
Ensure filter strings are correctly quoted and formatted.