#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
Share on:
comments powered by Disqus