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
---- ----------- -----------





Tagged as:

Leave a Response