Home » PowerShell » PowerShell Get All Computers in Domain

PowerShell Get All Computers in Domain

The command to get all computers in the domain and their details is the Get-AdComputer cmdlet in PowerShell. This command retrieves the computers in the Active Directory.

PowerShell list All Computers in Domain
PowerShell list All Computers in the Domain

In this article, we will discuss how to get all computers in the domain using the PowerShell Get-AdComputer cmdlet.

Find All Computers in the Domain in PowerShell

Get-ADComputer -Filter * -Properties  * | Select Name, DistinguishedName

In the above PowerShell script, the Get-AdComputer command uses the Filter parameter to get a list of all computers in the domain and display the computer name and distinguished names.

The output of the above PowerShell script to retrieve all computers in the AD domain is:

PS C:\> Get-ADComputer -Filter * -Properties  * | Select Name, DistinguishedName

Name        DistinguishedName
----        -----------------
ENGG-PRO    CN=ENGG-PRO,OU=Domain Controllers,DC=SHELLPRO,DC=LOCAL
OPER-01     CN=OPER-01,CN=Computers,DC=SHELLPRO,DC=LOCAL
OPER-2      CN=OPER-2,OU=SALES,DC=SHELLPRO,DC=LOCAL
OPER-3      CN=OPER-3,OU=SALES,DC=SHELLPRO,DC=LOCAL
CORP-IT-E12 CN=CORP-IT-E12,OU=SALES,DC=SHELLPRO,DC=LOCAL


PS C:\>

It is important to note, the command Get-AdComputer Filter * searches for all computers in the Active Directory and retrieves the details of the computer.

If the Active Directory size is huge, this command will time out. It’s better to use the SearchBase parameter to search within the scope like getting computers from the OU.

Conclusion

I hope the above article on how to get all computers in the domain using the PowerShell Get-AdComputer cmdlet is helpful to you.

You can find more topics about PowerShell Active Directory commands and PowerShell basics on the ShellGeek home page.