#PSTip List all AD attributes currently in use for AD users

This question was asked on the forums recently, is it possible to list all the Active Directory attributes that are currently in use for Active Directory users. It turns out this is relatively simple to do in PowerShell.
When creating a DirectorySearcher object, the default behavior is to only return the properties that have a value.
Because of this behavior we can easily list all properties available on all user objects.

By piping this output into Group-Object we can get an overview of all attributes that are in use by all Active Directory users and the number of times they are used.

$Searcher = New-Object DirectoryServices.DirectorySearcher
$Searcher.Filter = '(objectcategory=user)'
$Searcher.PageSize = 500
$Searcher.FindAll() | ForEach-Object {
} | Group-Object

About the author: Jaap Brasser

Jaap is a Senior System Engineer in the Financial Services industry. He focuses on Microsoft and related technologies and has a passion for PowerShell. In his spare time he maintains his Blog, Twitter feed, @Jaap_Brasser, and contributes on the Official Scripting Guys Forum and Windows PowerShell TechNet forums

Related Posts