1

#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 {
    $_.Properties.Keys
} | Group-Object
Filed in: Columns, Tips and Tricks Tags: , , ,

One Response to "#PSTip List all AD attributes currently in use for AD users"

Leave a Reply

Submit Comment

© 2016 PowerShell Magazine. All rights reserved. XHTML / CSS Valid.
Proudly designed by Theme Junkie.
%d bloggers like this: