Find an active directory users organizational unit (OU) using Powershell
February 22, 2012 5 Comments
Have you ever forgotten which organizational unit an active directory user resides in? You can use ‘Active Directory Users and Computers’ to quickly find the user using the ‘Find’ function but this doesn’t easily tell you which OU they belong to. Here is a very quick command to find the organizational unit (OU) that a user belongs to using Powersell, where USERNAME is the username of the user you wish to examine. Simply run the Powershell, and then enter:
Get-ADUser USERNAME
This will return the users details, including the Distinguished Name of their account, which will show which OU they belong to.
If you don’t know their username, you can use the filter option to search by firstname or surname. Here is an example filtering by surname where USER_SURNAME is the users surname:
Get-ADUser -filter {Surname -like “USER_SURNAME“}