PowerShell Genie

Find users without a manager

Script 2 min read Windows PowerShell 5.1 and PowerShell 7

Documentation: Microsoft Learn

The query pulls enabled users with the Manager attribute requested, filters down to accounts where that attribute is unpopulated, and reports the account name.

The script

1PS> Get-ADUser -Filter "Enabled -eq $true" -Properties Manager | Where-Object { -not $_.Manager } | Select-Object SamAccountName,Name

Script reader

Inspect before you run

Inspection only

Inspect the script below. It does not run in this browser.

Inspection only — no command has run.

    Show reference output

    Illustrative rows: Manager is empty for the returned accounts.

    SamAccountName Name
    -------------- ----
    msen           Mira Sen
    adas           Asha Das
    Inspect this example’s structure

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

    Get-ADUser -Filter "Enabled -eq $true" -Properties Manager | Where-Object { -not $_.Manager } | Select-Object SamAccountName,Name
    1. Stage 1Get-ADUser-Filter -Properties
    2. Stage 2Where-ObjectPositional values or no named parameters
    3. Stage 3Select-ObjectPositional values or no named parameters

      How it works

      The query pulls enabled users with the Manager attribute requested, filters down to accounts where that attribute is unpopulated, and reports the account name.

      Adapting it

      Group the results on the OU portion of DistinguishedName to see whether the gap clusters in one business unit, which usually points at a single broken provisioning path rather than scattered mistakes.

      Requirements

      ActiveDirectory module.

      If the result is unexpected

      Users appear to have no manager even though the organization chart shows one.

      The AD manager attribute may be empty, stale or maintained in a different system.

      1. Read the manager distinguished name for a sample user and check whether the referenced directory object resolves.

      Validate the result

      Missing manager values are distinguished from references to removed or incorrect objects.

      Keep the check reliable

      Validate manager references during onboarding and organizational changes.

      Primary documentation

      PowerShell objects and pipelines documentation

      Continue
      Genie guideFind users without a manager

      The query pulls enabled users with the Manager attribute requested, filters down to accounts where that attribute is unpopulated, and reports the account name.