Add Computer - PowerShell


Add-Computer is a PowerShell command used to add a remote computer to the current Active Directory domain or workgroup. It simplifies the process of onboarding new devices by automating the necessary configuration and joining procedures.


Add-Computer -ComputerName <String> [-Domain <String>] [-Credential <PSCredential>]
[-OUPath <String>] [-Restart <Switch>] [-NoRestart <Switch>] [-LocalAccount <String>] [-DisplayName <String>]
[-Description <String>] [-ServiceAccount <String>] [-Password <SecureString>] [-Authentication <AuthenticationType>]
[-ErrorAction <ActionPreference>] [-WarningAction <ActionPreference>] [-Verbose] [-Debug] [-WhatIf] [-Confirm]


| Option/Flag | Description | Default |
| -ComputerName | Specifies the name of the computer to be added. | Required |
| -Domain | The domain to which the computer should be added. | Current user’s domain |
| -Credential | Credentials with permissions to add the computer to the domain. | Current user’s credentials |
| -OUPath | The Organizational Unit (OU) within the domain to which the computer should be added. | Root of the domain |
| -Restart | Automatically restarts the computer after adding it to the domain. | False |
| -NoRestart | Prevents the computer from restarting after adding it to the domain. | False |
| -LocalAccount | Specifies the local account to be used for the computer after joining the domain. | Default local account |
| -DisplayName | Sets the display name of the computer in Active Directory. | ComputerName |
| -Description | Sets the description of the computer in Active Directory. | None |
| -ServiceAccount | Specifies a managed service account to use for the computer. | None |
| -Password | The password for the specified local account or service account. | Required if using a local account |
| -Authentication | Specifies the authentication method. Valid values: ‘Kerberos’ (default), ‘Basic’, ‘Negotiate’. | ‘Kerberos’ |



Add-Computer -ComputerName new-computer

Adding to a specific domain:

Add-Computer -ComputerName new-workstation -Domain workgroup.local

Restarting the computer after joining:

Add-Computer -ComputerName new-server -Restart

Specifying a local account and password:

$password = ConvertTo-SecureString "myPassword" -AsPlainText -Force
Add-Computer -ComputerName new-laptop -LocalAccount myaccount -Password $password

Common Issues

  • Computer cannot be joined: Ensure that the computer is connected to the domain network, has a valid IP address, and that the specified credentials have sufficient permissions.
  • Computer does not restart: Verify that the -Restart parameter was used or the computer is configured to restart automatically after joining the domain.
  • Local account not created: Ensure that the specified local account exists on the computer and that the password is correct.


Add-Computer can be used in conjunction with other PowerShell commands to automate onboarding tasks:

  • Get-ADDomain: Retrieve information about the domain to which the computer is being added.
  • New-ADUser: Create a local user account on the computer.
  • Install-WindowsFeature: Install necessary Windows features on the computer.
  • Set-ComputerName: Change the computer’s name after it has been added to the domain.