PowerShell Genie

Set-ADComputer

Use Set-ADComputer to modify attributes on an existing Active Directory computer account.

Command 2 min read Windows PowerShell 5.1 and PowerShell 7

Documentation: Microsoft Learn — Set-ADComputer

Syntax

1PS> Set-ADComputer [-Identity] <ADComputer> [-Description <String>] [-Location <String>] [-ManagedBy <ADPrincipal>] [-Enabled <Boolean>] [-Replace <Hashtable>] [-Add <Hashtable>] [-Clear <String[]>] [-TrustedForDelegation <Boolean>] [-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-ADComputer [-Identity] <ADComputer> [-Description <String>] [-Location <String>] [-ManagedBy <ADPrincipal>] [-Enabled <Boolean>] [-Replace <Hashtable>] [-Add <Hashtable>] [-Clear <String[]>] [-TrustedForDelegation <Boolean>] [-WhatIf] [<CommonParameters>]
  1. Stage 1Set-ADComputer-Identity -Description -Location -ManagedBy -Enabled -Replace -Add -Clear -TrustedForDelegation -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-ADComputer -Identity SRV01

    1PS> Set-ADComputer -Identity SRV01 -Description "App server, owned by platform team"
    Show reference output

    Sample output · fictional data, shaped like the real thing

    Description       : App server, owned by platform team
    DistinguishedName : CN=SRV01,OU=Servers,DC=corp,DC=local
    DNSHostName       : SRV01.corp.local
    Enabled           : True
    Name              : SRV01
    ObjectClass       : computer

    Set-ADComputer -Identity SRV01 (2)

    1PS> Set-ADComputer -Identity SRV01 -Add @{ servicePrincipalName = "HTTP/app.corp.local" }
    Show reference output

    Sample output · fictional data, shaped like the real thing

    DistinguishedName     : CN=SRV01,OU=Servers,DC=corp,DC=local
    Name                  : SRV01
    ServicePrincipalNames : {HOST/SRV01, HOST/SRV01.corp.local, HTTP/app.corp.local}

    Get-ADComputer -Properties servicePrincipalName

    1PS> Get-ADComputer SRV01 -Properties servicePrincipalName | Select-Object -ExpandProperty servicePrincipalName
    Show reference output

    Sample output · fictional data, shaped like the real thing

    HOST/SRV01
    RestrictedKrbHost/SRV01
    HOST/SRV01.corp.local

    Parameters

    Parameter definitions:

    • -Identity
    • -Description
    • -Location
    • -ManagedBy
    • -Enabled
    • -Replace
    • -Add
    • -Clear
    • -TrustedForDelegation
    • -WhatIf

    Set-ADComputer on Microsoft Learn

    Practical use and troubleshooting

    Practical scenario: Use Set-ADComputer when you need to modify attributes on an existing Active Directory computer account. 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: A missing identity can mean the computer account is in another domain or has a different name. Resolve it in the intended directory before modifying attributes. 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-ADComputer. New-ADComputer creates a computer account; Set-ADComputer updates attributes of an existing one. Creating the account alone does not join a Windows computer to the domain. Read the linked command before substituting it; similar names do not imply identical inputs or output.

    Set-ADComputer reference on Microsoft Learn

    Recap

    Set-ADComputer Use Set-ADComputer to modify attributes on an existing Active Directory computer account.

    Next: Set-ADUser
    Genie guideSet-ADComputer

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