Skip to content

PowerShell: Getting properties for all user objects in a given OU

Two weeks ago, I showed you how I got some specific properties for a specific user. Perhaps unsurprisingly, the next request from my customer was a similar dump from a specific OU. While the Identity parameter works well when you’re dealing with a specific user, it doesn’t help when you want all users.

Furthermore, they requested an overview showing only users in a specific OU, For this, we need to use the SearchBase parameter, together with a wildcarded Filter parameter, like so: Get-ADUser -Filter * -SearchBase "OU=Finance,OU=UserAccounts,DC=FABRIKAM,DC=COM"

Tacking on the properties we wanted, the final query looks like this:Get-ADUser -Filter * -SearchBase "OU=Finance,OU=UserAccounts,DC=FABRIKAM,DC=COM" -properties CN, DisplayName, LastLogonDate, Manager

The output gets a little chaotic, so I will show you how to get it into CSV format next week.

By posting a comment, you consent to our collecting the information you enter. See privacy policy for more information.

This site uses Akismet to reduce spam. Learn how your comment data is processed.