Share via


Joining a Computer to a Domain

Applies To: Windows Server 2008 R2

This topic explains how to use the Active Directory module for Windows PowerShell to join a computer to a domain.

Example 1

The following example demonstrates how to add the local computer to the Fabrikam.com domain by using the current logged-on user credentials. You must run this command on the local computer:

Add-Computer -DomainOrWorkgroupName Fabrikam

Example 2

The following example demonstrates how to add the computer FabrikamClient1 to the FabrikamGroup workgroup using the current logged-on user credentials. You must run this command on the local computer:

Add-Computer -FabrikamClient1 -WGN FabrikamGroup

Example 3

The following example demonstrates how to add the computer S1 to the domain Fabrikam.com. The domain controller that performs the join is specified by the -Server parameter, using the current logged-on user credentials. You must run this command on the local computer:

Add-Computer S1 -DN Fabrikam -Server FabrikamDC1

Example 4

The following example demonstrates how to add the local computer on which this command is being executed to the Fabrikam.com domain. The local computer is added to the organizational unit (OU) in the directory that is specified by the OUPath parameter, using the current logged-on user credentials. You must run this command on the local computer:

Add-Computer -DomainOrWorkgroupName Fabrikam -OUPath OU=testOU,DC=domain,DC=Domain,DC=com

Example 5

The following example demonstrates how to add the computer S1 to the Fabrikam.com domain using the specified credentials Fabrikam\Administrator. When the operation is complete, the computer restarts automatically. You must run this command on the local computer:

Add-Computer S1 Fabrikam Fabrikam\Administrator -Reboot

Additional information

For a full explanation of the parameters that you can pass to Add-Computer, at the Active Directory module command prompt, type Get-Help Add-Computer –detailed, and then press ENTER.