Find an active directory users organizational unit (OU) using Powershell

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.

Using Get-ADUser to obtain OU information

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“}

Advertisements

4 Responses to Find an active directory users organizational unit (OU) using Powershell

  1. L. Toro says:

    L.Toro says: You need excute this command before:

    PS C:\> import-module activedirectory

    • oasysadmin says:

      You are quite right L. Toro, although you can also simply run ‘Active Directory Module for Windows Powershell’ from the Administrative Tools menu as I did for the same result.

  2. Pingback: Out with the old, in with … AGEE VPX (part 3) « virtuEs.IT

  3. Pingback: Powershell Get Users Ou | Liyongbak

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: