PowerShell Genie

Get-ADOrganizationalUnit

Use Get-ADOrganizationalUnit to list Active Directory OUs with their distinguished names — the containers Group Policy and delegated administration target.

Command 2 min read Windows PowerShell 5.1 and PowerShell 7

Documentation: Microsoft Learn — Get-ADOrganizationalUnit

Syntax

1PS> Get-ADOrganizationalUnit [-Identity] <ADOrganizationalUnit> [-Filter <String>] [-SearchBase <String>] [-SearchScope <ADSearchScope>] [-Properties <String[]>] [-Server <String>] [<CommonParameters>]
See the command anatomy

Read the command and its supplied arguments. This example requires real PowerShell or its module; this diagram does not execute it.

Get-ADOrganizationalUnit [-Identity] <ADOrganizationalUnit> [-Filter <String>] [-SearchBase <String>] [-SearchScope <ADSearchScope>] [-Properties <String[]>] [-Server <String>] [<CommonParameters>]
  1. Stage 1Get-ADOrganizationalUnit-Identity -Filter -SearchBase -SearchScope -Properties -Server

    Try it

    Windows PowerShell

    PowerShell example · browser support is limited.

    Execution scope: The full example below requires PowerShell outside this browser. You can edit this runner to use the supported practice commands; unsupported syntax returns an explanation.

    Interactive simulation · fictional data

    Examples

    Get-ADOrganizationalUnit -Filter *

    1PS> Get-ADOrganizationalUnit -Filter * | Select-Object Name, DistinguishedName
    Show reference output

    Sample output · fictional data, shaped like the real thing

    Name      DistinguishedName
    ----      -----------------
    Sales     OU=Sales,DC=corp,DC=local
    Servers   OU=Servers,DC=corp,DC=local

    Get-ADOrganizationalUnit -Filter * (2)

    1PS> Get-ADOrganizationalUnit -Filter * -Properties LinkedGroupPolicyObjects | Select-Object Name, LinkedGroupPolicyObjects
    Show reference output

    Sample output · fictional data, shaped like the real thing

    Name      LinkedGroupPolicyObjects
    ----      ------------------------
    Sales     {cn={31B2F340-016D-11D2-945F-00C04FB984F9},cn=policies,cn=system,DC=corp,DC=local}
    Servers   {}

    Get-ADOrganizationalUnit -Filter * (3)

    1PS> Get-ADOrganizationalUnit -Filter * -SearchBase "DC=corp,DC=local" -SearchScope OneLevel
    Show reference output

    Sample output · fictional data, shaped like the real thing

    Name      DistinguishedName
    ----      -----------------
    Sales     OU=Sales,DC=corp,DC=local
    Servers   OU=Servers,DC=corp,DC=local

    Parameters

    Parameter definitions:

    • -Identity
    • -Filter
    • -SearchBase
    • -SearchScope
    • -Properties
    • -Server

    Get-ADOrganizationalUnit on Microsoft Learn

    Practical use and troubleshooting

    Practical scenario: Use Get-ADOrganizationalUnit when you need to list Active Directory OUs with their distinguished names — the containers Group Policy and delegated administration target. Start with one identified target and inspect the returned values before extending the operation to a list. Keep the identity in your report so you can trace each result back to the object or path that produced it.

    Common error and fix: An OU-not-found result may mean the distinguished name points to a container rather than an OU. Inspect the object class and correct the search base before applying OU-specific logic. In an unattended script, capture this failure with its original error record and record which target failed. An empty result and an unsuccessful query must remain distinguishable in the final report.

    See also: Get-ADObject. Get-ADObject searches directory objects across classes; Get-ADOrganizationalUnit returns OU objects. An OU query is a clearer choice when the task concerns organisational containers. Read the linked command before substituting it; similar names do not imply identical inputs or output.

    Get-ADOrganizationalUnit reference on Microsoft Learn

    Recap

    Get-ADOrganizationalUnit Use Get-ADOrganizationalUnit to list Active Directory OUs with their distinguished names — the containers Group Policy and delegated administration target.

    Next: Get-ADGroupMember
    Genie guideGet-ADOrganizationalUnit

    Use Get-ADOrganizationalUnit to list Active Directory OUs with their distinguished names — the containers Group Policy and delegated administration target. The console below is pre-loaded — run it, then change a value and run it again.