My PowerShell

Windows Powershell scripts, examples, tips, docs …

How to retrieve a list of Computer Accounts from Active Directory

The Get-ADComputer cmdlet gets a computer or performs a search to retrieve multiple computers.

Examples: how to get all computers:

Get-ADComputer -Filter * | export-csv c:\temp\all_comp_obj.csv

 

Also, it is easy to remove some computer (from csv file RemoveComps.csv):

Import-CSV c:\temp\RemoveComps.csv | ForEach { Remove-ADComputer -Identity $_.comp -confirm:$false }

 

Get all the computers with a name starting by a particular string and showing the name, dns hostname and IPv4 address.

Get-ADComputer -Filter ‘Name -like “Fabrikam*”‘ -Properties IPv4Address | FT Name,DNSHostName,IPv4Address -A
 

name dnshostname ipv4address
---- ----------- -----------
FABRIKAM-SRV1 FABRIKAM-SRV1.Fabrikam.com 10.194.99.181
FABRIKAM-SRV2 FABRIKAM-SRV2.Fabrikam.com 10.194.100.37
 

 

 

 

 

Tagged as:

Leave a Response