PowerShell Genie

Get-ADObject

Use Get-ADObject to retrieve any object from Active Directory regardless of type, including deleted objects.

Command 2 min read Windows PowerShell 5.1 and PowerShell 7

Documentation: Microsoft Learn — Get-ADObject

Syntax

1PS> Get-ADObject [-Identity] <ADObject> [-Filter <String>] [-LDAPFilter <String>] [-SearchBase <String>] [-Properties <String[]>] [-IncludeDeletedObjects] [-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-ADObject [-Identity] <ADObject> [-Filter <String>] [-LDAPFilter <String>] [-SearchBase <String>] [-Properties <String[]>] [-IncludeDeletedObjects] [-Server <String>] [<CommonParameters>]
  1. Stage 1Get-ADObject-Identity -Filter -LDAPFilter -SearchBase -Properties -IncludeDeletedObjects -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-ADObject -Filter 'objectClass -eq "contact"'

    1PS> Get-ADObject -Filter 'objectClass -eq "contact"' -Properties Name, Mail
    Show reference output

    Sample output · fictional data, shaped like the real thing

    Name          Mail
    ----          ----
    Sales Contact sales@example.test

    Get-ADObject -Filter 'isDeleted -eq $true'

    1PS> Get-ADObject -Filter 'isDeleted -eq $true' -IncludeDeletedObjects -Properties LastKnownParent
    Show reference output

    Sample output · fictional data, shaped like the real thing

    Name        LastKnownParent
    ----        ---------------
    Former User OU=Users,DC=example,DC=test

    Get-ADObject -LDAPFilter "(objectClass=site)"

    1PS> Get-ADObject -LDAPFilter "(objectClass=site)" -SearchBase "CN=Configuration,DC=corp,DC=local"
    Show reference output

    Sample output · fictional data, shaped like the real thing

    Name                     ObjectClass
    ----                     -----------
    Default-First-Site-Name  site

    Parameters

    Parameter definitions:

    • -Identity
    • -Filter
    • -LDAPFilter
    • -SearchBase
    • -Properties
    • -IncludeDeletedObjects
    • -Server

    Get-ADObject on Microsoft Learn

    Practical use and troubleshooting

    Practical scenario: Use Get-ADObject when you need to retrieve any object from Active Directory regardless of type, including deleted objects. 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 empty result can come from an incorrect LDAP filter or search base. Test a narrow known object, then widen the filter only after confirming the directory scope. 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-ADOrganizationalUnit. 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-ADObject reference on Microsoft Learn

    Recap

    Get-ADObject Use Get-ADObject to retrieve any object from Active Directory regardless of type, including deleted objects.

    Next: Move-ADObject
    Genie guideGet-ADObject

    Use Get-ADObject to retrieve any object from Active Directory regardless of type, including deleted objects. The console below is pre-loaded — run it, then change a value and run it again.