Add-Computer

Add the local computer to a domain or workgroup. Move a computer account from one domain to another. Add-Computer will create new domain computer accounts as required.

Syntax
      Add-Computer [-DomainName] string [-ComputerName String[]]
         [-Force] [-LocalCredential PSCredential] [-NewName String]
            [-Options { AccountCreate | DeferSPNSet | InstallInvoke | JoinReadOnly
                        | JoinWithNewName | PasswordPass | UnsecuredJoin | Win9XUpgrade} ]
                 [-OUPath String] [-PassThru] [-Restart] [-Server String]
                    [-UnjoinDomainCredential PSCredential] [-Unsecure]
                       [-Credential PSCredential] 
                          [-Confirm] [-WhatIf] [CommonParameters]
    
      Add-Computer [-WorkGroupName] string [-ComputerName String[]]
         [-Credential PSCredential] [-Force] [-LocalCredential PSCredential]
            [-NewName String] [-PassThru] [-Restart] [-Confirm] [-WhatIf] [CommonParameters]

key
   -DomainName string
       A domain for the computer account. This parameter is required.

   -ComputerName String[]
       The computer(s) to add to a domain or workgroup. Default=the local computer.
       A NetBIOS name, IP address, or a fully qualified domain name. (PowerShell 3.0+)

   -Credential
       A user account that has permission to Add computers.
       A user name, such as "User64" or "Domain64\User64", or a PSCredential object.
       If you supply a user name, you will be prompted for a password.
       The default is the current user.

   -LocalCredential PSCredential
       Specifies a user account that has permission to connect to the computers
       specified by ComputerName.
       A user name, such as "User64" or "Domain64\User64", or a PSCredential object.
       If you supply a user name, you will be prompted for a password.
       Default=current user. (PowerShell 3.0+)

    -UnjoinDomainCredential PSCredential
       Specifies a user account that has permission to remove the computer(s) from
       their current domains.
       A user name, such as "User64" or "Domain64\User64", or a PSCredential object. 
       If you supply a user name, you will be prompted for a password.
       Default=current user. (PowerShell 3.0+)

   -Force
       Don’t confirm the addition of each computer. (PowerShell 3.0+)

   -NewName String
       Specifies a new name for the computer in the new domain. (PowerShell 3.0+)
       This parameter is valid only when one computer is being added or moved.

    -Options JoinOptions          (PowerShell 3.0+)
       Enter one or more advanced options in a comma-separated string:

        -- AccountCreate : Create a domain account. Add-Computer automatically creates
           a domain account when it adds a computer to a domain. This option is included for completeness.

        -- Win9XUpgrade : Indicates that the join operation is part of an OS upgrade.

        -- UnsecuredJoin: Perform an unsecured join. Use the -Unsecure parameter or this option.

        -- PasswordPass : Set the machine password to the value of the Credential (DomainCredential) parameter after
          performing an unsecured join. This option also indicates that the value of the Credential (DomainCredential)
          parameter is a machine password, not a user password. This option is valid only when the UnsecuredJoin option
          is specified.

        -- JoinWithNewName : Rename the computer name in the new domain to the name specified by the NewName
          parameter. When you use the NewName parameter, this option is set automatically. This option is designed to be
          used with the Rename-Computer cmdlet. If you use the Rename-Computer cmdlet to rename the computer, but do not
          restart the computer to make the change effective, you can use this parameter to join the computer to a domain
          with its new name.

        -- JoinReadOnly : Use an existing machine account to join the computer to a read-only domain controller.
          The machine account must be added to the allowed list for password replication policy and the account password
          must be replicated to the read-only domain controller prior to the join operation.

        -- InstallInvoke: Set the create (0x2) and delete (0x4) flags of the FJoinOptions parameter of the
          JoinDomainOrWorkgroup method.

   -OUPath string
       An organizational unit (OU) distinguished name for the domain account.
       Default value = the default OU for machine objects. 
 
   -PassThru
       Pass the object created by this cmdlet through the pipeline.

   -Restart
       Restart the computers that were added to the domain or workgroup.
       A restart is often required to make the change effective. (PS 3.0+)

   -Server DomainName\ComputerName
       The domain controller that will add the computer to the domain.
       By default, no domain controller is specified.

   -Unsecure
       Perform an unsecure join

   -WorkGroupName string
       The name of a work group for the computer. The default value is "WORKGROUP"
       If you omit this parameter, the computer is joined to a domain.

   -whatIf
       Describe the command without actually executing it.

   -confirm
       Prompt for confirmation before executing the command.

Examples

Add the local computer to the SS64dom domain using the credentials of the current user:

PS C:\> add-computer -domainname SS64Dom -restart

Add a local computer to a workgroup:

PS C:\> Add-Computer -WorkGroupName "WORKGROUP64"

Add the local computer to the SS64dom domain by using the SS64Dom\DC01 domain controller:

PS C:\> add-computer -DomainName SS64Dom -Server SS64Dom\DC01 -passthru -verbose

Add the local computer to the SS64dom domain and place in a specific OU:

PS C:\> Add-Computer -domainname SS64Dom -OUPath "OU=Sales,DC=SS64,DC=com" -cred SS64Dom\Admin64 -passthru

Move a group of computers to a new domain:

PS C:\> Add-Computer -ComputerName "Server64", "Server65", "localhost" -Domain "SS64Dom" -LocalCredential oldDom\User01 -UnjoinDomainCredential oldDom\Admin01 -Credential SS64Dom\Admin64 -Restart

“Since time is the one immaterial object which we cannot influence--neither speed up nor slow down, add to nor diminish--it is an imponderably valuable gift” ~ Maya Angelou

Related PowerShell Cmdlets

Checkpoint-Computer - Create a system restore point on the local computer.
NETDOM JOIN - Join a workstation or member server to the domain.


 
Copyright © 1999-2024 SS64.com
Some rights reserved