PowerShell Logo Small

Add-Computer



This is the built-in help made by Microsoft for the command 'Add-Computer', in PowerShell version 5 - as retrieved from Windows version 'Microsoft Windows Server 2012 R2 Standard' PowerShell help files on 2016-06-23.

For PowerShell version 3 and up, where you have Update-Help, this command was run just before creating the web pages from the help files.

SYNOPSIS

Add the local computer to a domain or workgroup.

SYNTAX


Add-Computer [-DomainName] <String> [-ComputerName [<String[]>]] [-Force] [-InformationAction {SilentlyContinue | Stop | Continue | Inquire | Ignore | Suspend}]
[-InformationVariable [<System.String]>]] [-LocalCredential [<PSCredential>]] [-NewName [<String>]] [-Options {AccountCreate | Win9XUpgrade | UnsecuredJoin | PasswordPass |
DeferSPNSet | JoinWithNewName | JoinReadOnly | InstallInvoke}] [-OUPath [<String>]] [-PassThru] [-Restart] [-Server [<String>]] [-UnjoinDomainCredential [<PSCredential>]]
[-Unsecure] -Credential <PSCredential> [-Confirm] [-WhatIf] [<CommonParameters>]
Add-Computer [-WorkgroupName] <String> [-ComputerName [<String[]>]] [-Credential <PSCredential>] [-Force] [-InformationAction {SilentlyContinue | Stop | Continue | Inquire |
Ignore | Suspend}] [-InformationVariable [<System.String]>]] [-LocalCredential [<PSCredential>]] [-NewName [<String>]] [-PassThru] [-Restart] [-Confirm] [-WhatIf]
[<CommonParameters>]



Search powershellhelp.space

DESCRIPTION


The Add-Computer cmdlet adds the local computer or remote computers to a domain or workgroup, or moves them from one domain to another. It also creates a domain account if
the computer is added to the domain without an account.


You can use the parameters of this cmdlet to specify an organizational unit (OU) and domain controller or to perform an unsecure join.


To get the results of the command, use the Verbose and PassThru parameters.



<

RELATED LINKS

Online Version: http://go.microsoft.com/fwlink/p/?linkid=289795
Checkpoint-Computer
Remove-Computer
Restart-Computer
Rename-Computer
Restore-Computer
Stop-Computer
Test-Connection

REMARKS

<

Examples


-------------------------- EXAMPLE 1 --------------------------

PS C:\>Add-Computer -DomainName Domain01 -Restart



This command adds the local computer to the Domain01 domain and then restarts the computer to make the change effective.






-------------------------- EXAMPLE 2 --------------------------

PS C:\>Add-Computer -WorkGroupName WORKGROUP-A



This command adds the local computer to the Workgroup-A workgroup.






-------------------------- EXAMPLE 3 --------------------------

PS C:\>Add-Computer -DomainName Domain01 -Server Domain01\DC01 -Passthru -Verbose



This command adds the local computer to the Domain01 domain by using the Domain01\DC01 domain controller.

The command uses the PassThru and Verbose parameters to get detailed information about the results of the command.






-------------------------- EXAMPLE 4 --------------------------

PS C:\>Add-Computer -DomainName Domain02 -OUPath "OU=testOU,DC=domain,DC=Domain,DC=com"



This command adds the local computer to the Domain02 domain. It uses the OUPath parameter to specify the organizational unit for the new accounts.






-------------------------- EXAMPLE 5 --------------------------

PS C:\>Add-Computer -ComputerName Server01 -LocalCredential Server01\Admin01 -DomainName Domain02 -Credential Domain02\Admin02 -Restart -Force



This command adds the Server01 computer to the Domain02 domain. It uses the LocalCredential parameter to specify a user account that has permission to connect to the
Server01 computer. It uses the Credential parameter to specify a user account that has permission to join computers to the domain. It uses the Restart parameter to restart
the computer after the join operation completes and the Force parameter to suppress user confirmation messages.






-------------------------- EXAMPLE 6 --------------------------

PS C:\>Add-Computer -ComputerName Server01, Server02, localhost -Domain Domain02 -LocalCredential Domain01\User01 -UnjoinDomainCredential Domain01\Admin01 -Credential
Domain02\Admin01 -Restart



This command moves the Server01 and Server02 computers, and the local computer, from Domain01 to Domain02.

It uses the LocalCredential parameter to specify a user account that has permission to connect to the three affected computers. It uses the UnjoinDomainCredential parameter
to specify a user account that has permission to unjoin the computers from the Domain01 domain and the Credential parameter to specify a user account that has permission to
join the computers to the Domain02 domain. It uses the Restart parameter to restart all three computers after the move is complete.






-------------------------- EXAMPLE 7 --------------------------

PS C:\>Add-Computer -ComputerName Server01 -Domain Domain02 -NewName Server044 -Credential Domain02\Admin01 -Restart



This command moves the Server01 computer to the Domain02 and changes the machine name to Server044.

The command uses the credential of the current user to connect to the Server01 computer and unjoin it from its current domain. It uses the Credential parameter to specify a
user account that has permission to join the computer to the Domain02 domain.






-------------------------- EXAMPLE 8 --------------------------

PS C:\>Add-Computer -ComputerName (Get-Content Servers.txt) -Domain Domain02 -Credential Domain02\Admin02 -Options Win9xUpgrade -Restart



This command adds the computers that are listed in the Servers.txt file to the Domain02 domain. It uses the Options parameter to specify the Win9xUpgrade option. The Restart
parameter restarts all of the newly added computers after the join operation completes.