PowerShell Genie

New-ADComputer

Use New-ADComputer to create a computer account in Active Directory before the machine joins the domain.

Command 2 min read Windows PowerShell 5.1 and PowerShell 7

Documentation: Microsoft Learn — New-ADComputer

Syntax

1PS> New-ADComputer [-Name] <String> [-Path <String>] [-SamAccountName <String>] [-Enabled <Boolean>] [-Description <String>] [-Location <String>] [-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.

New-ADComputer [-Name] <String> [-Path <String>] [-SamAccountName <String>] [-Enabled <Boolean>] [-Description <String>] [-Location <String>] [-WhatIf] [<CommonParameters>]
  1. Stage 1New-ADComputer-Name -Path -SamAccountName -Enabled -Description -Location -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

    New-ADComputer -Name SRV02

    1PS> New-ADComputer -Name SRV02 -Path "OU=Servers,DC=corp,DC=local" -Description "App server"
    Show reference output

    Sample output · fictional data, shaped like the real thing

    Name  SamAccountName DNSHostName      Enabled
    ----  -------------- -----------      -------
    SRV02 SRV02$         SRV02.corp.local True

    Get-ADComputer -Identity SRV02

    1PS> Get-ADComputer -Identity SRV02 | Select-Object Name, DistinguishedName
    Show reference output

    Sample output · fictional data, shaped like the real thing

    Name   DistinguishedName
    -----  ------------------------------------
    SRV01  CN=SRV01,OU=Servers,DC=corp,DC=local
    SRV02  CN=SRV02,OU=Servers,DC=corp,DC=local

    Get-ADComputer -Filter *

    1PS> Get-ADComputer -Filter * -SearchBase "CN=Computers,DC=corp,DC=local" | Select-Object Name
    Show reference output

    Sample output · fictional data, shaped like the real thing

    Name
    -----
    SRV01
    SRV02

    Parameters

    Parameter definitions:

    • -Name
    • -Path
    • -SamAccountName
    • -Enabled
    • -Description
    • -Location
    • -WhatIf

    New-ADComputer on Microsoft Learn

    Practical use and troubleshooting

    Practical scenario: Use New-ADComputer when you need to create a computer account in Active Directory before the machine joins the domain. 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 duplicate-name error needs checking whether the computer account already exists. Confirm the intended OU and reuse policy before creating another directory object. 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: Set-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.

    New-ADComputer reference on Microsoft Learn

    Recap

    New-ADComputer Use New-ADComputer to create a computer account in Active Directory before the machine joins the domain.

    Next: Set-ADComputer
    Genie guideNew-ADComputer

    Use New-ADComputer to create a computer account in Active Directory before the machine joins the domain. The console below is pre-loaded — run it, then change a value and run it again.