PowerShell Genie

Set-ADUser

Use Set-ADUser to modify attributes on an existing Active Directory user account.

Command 2 min read Windows PowerShell 5.1 and PowerShell 7

Documentation: Microsoft Learn — Set-ADUser

Syntax

1PS> Set-ADUser [-Identity] <ADUser> [-Replace <Hashtable>] [-Add <Hashtable>] [-Remove <Hashtable>] [-Clear <String[]>] [-Enabled <Boolean>] [-Department <String>] [-Manager <ADUser>] [-WhatIf] [<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.

Set-ADUser [-Identity] <ADUser> [-Replace <Hashtable>] [-Add <Hashtable>] [-Remove <Hashtable>] [-Clear <String[]>] [-Enabled <Boolean>] [-Department <String>] [-Manager <ADUser>] [-WhatIf] [<CommonParameters>]
  1. Stage 1Set-ADUser-Identity -Replace -Add -Remove -Clear -Enabled -Department -Manager -WhatIf

    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

    Set-ADUser -Identity jsmith

    1PS> Set-ADUser -Identity jsmith -Department Sales -Title "Account Manager"
    Show reference output

    Sample output · fictional data, shaped like the real thing

    Department        : Sales
    DistinguishedName : CN=John Smith,OU=Users,DC=corp,DC=local
    Name              : John Smith
    SamAccountName    : jsmith
    Title             : Account Manager

    Set-ADUser -Identity jsmith (2)

    1PS> Set-ADUser -Identity jsmith -Replace @{ physicalDeliveryOfficeName = "London" }
    Show reference output

    Sample output · fictional data, shaped like the real thing

    DistinguishedName          : CN=John Smith,OU=Users,DC=corp,DC=local
    Name                       : John Smith
    physicalDeliveryOfficeName : London
    SamAccountName             : jsmith

    Get-ADUser -Filter 'Department -eq "Sales"'

    1PS> Get-ADUser -Filter 'Department -eq "Sales"' | Select-Object Name # read before you write
    Show reference output

    Sample output · fictional data, shaped like the real thing

    Name
    ----------
    Jane Smith
    Alex Jones

    Parameters

    Parameter definitions:

    • -Identity
    • -Replace
    • -Add
    • -Remove
    • -Clear
    • -Enabled
    • -Department
    • -Manager
    • -WhatIf

    Set-ADUser on Microsoft Learn

    Practical use and troubleshooting

    Practical scenario: Use Set-ADUser when you need to modify attributes on an existing Active Directory user account. Review syntax and sample output, then try an example in the browser lab. 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: Identity not found can result from passing a display name instead of an accepted identifier. Resolve the account first and use its distinguished name, GUID or other supported identity. 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: New-ADUser. New-ADUser creates a user object; Set-ADUser changes an existing one. Creation settings and subsequent account updates should be reviewed separately in a bulk provisioning workflow. Read the linked command before substituting it; similar names do not imply identical inputs or output.

    Set-ADUser reference on Microsoft Learn

    Recap

    Set-ADUser Use Set-ADUser to modify attributes on an existing Active Directory user account.

    Next: New-ADUser
    Genie guideSet-ADUser

    Use Set-ADUser to modify attributes on an existing Active Directory user account. The console below is pre-loaded — run it, then change a value and run it again.