![Netdom Netdom](/uploads/1/2/5/2/125294296/106060131.jpg)
Apr 27, 2010 - Explains the prerequisites, settings and steps required to join a. By using NETDOM you can accomplish the task of joining a domain from the. Invoke-VMScript -VM $vmname -GuestUser $VMLocalUser -GuestPassword $VMLocalPWord -ScriptType Powershell 'netdom join /d:mywork.domain.
-->Applies To: Windows Server 2008, Windows Server 2008 R2, Windows Server 2012, Windows 8
Joins a workstation or member server to a domain. The act of joining a computer to a domain creates an account for the computer on the domain, if it does not already exist.
Netdom is a command-line tool that is built into Windows Server 2008and Windows Server 2008 R2. It is available if you have the Active Directory Domain Services (AD DS) server role installed. It is also available if you install the Active Directory Domain Services Tools that are part of the Remote Server Administration Tools (RSAT). For more information, see How to Administer Microsoft Windows Client and Server Computers Locally and Remotely (https://go.microsoft.com/fwlink/?LinkID=177813).
To use netdom, you must run the netdom command from an elevated command prompt. To open an elevated command prompt, click Start, right-click Command Prompt, and then click Run as administrator.
For examples of how to use this command, see Examples.
Syntax
Parameters
Note
When you join a computer running Windows NT 4.0 or earlier to the domain, the operation is not transacted. This means that a failure during the operation might leave the computer in an undetermined state with respect to the domain to which you intended to join it.
Parameter | Description |
---|---|
<Computer> | Specifies the name of the computer that you want to join to the domain. |
{/d: | /domain:}<Domain> | Specifies the domain that you want to join the computer to. If you do not specify this parameter, then netdom join uses the domain to which the current computer belongs. |
/ou:<OUPath> | Specifies the organizational unit (OU) under which you want to create the account. You must specify the full RFC 1779 distinguished name of the OU. If you do not specify this parameter, netdom join creates the account under the default OU for computer objects for that domain. |
{/ud: | /userd:}[<Domain>]<User> | Specifies the user account that makes the connection with the domain that you specify in the /d or /domain parameter. If you do not specify this parameter, netdom join uses the current user account. |
{/pd: | /passwordd:}{<Password>|*} | Specifies the password of the user account that you specify in the /ud or /userd parameter. If you specify the value of this parameter as a wildcard character (*), this parameter prompts you for the password. |
{/uo: | /usero}<User> | Specifies the user account that makes the connection with the computer that you want to join to the domain. If you do not specify this parameter, netdom join uses the current user account. |
{/po: | /passwordo}{<Password>|*} | Specifies the password of the user account that you specify in the /uo or /usero parameter. If you specify the value of this parameter as a wildcard character (*), this parameter prompts you for the password. |
/reboot[:<Delay>] | Specifies to shut down the computer and automatically reboot after the join operation has completed. The Delay value is the number of seconds before automatic shutdown occurs. The default Delay value is 20 seconds. |
{/help | /?} | Displays help at the command prompt. |
Examples
To join mywksta to the devgroup.contoso.com domain in the Dsys/workstations OU, type the following command at the command prompt:
Besides adding the computer account to the domain, this command modifies the workstation to contain the appropriate shared secret to complete the Join operation.
Additional references
PermalinkJoin GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign up Find file Copy path
Cannot retrieve contributors at this time
# 'NETDOM JOIN %COMPUTERNAME%' for Windows 7 |
# @author Kenichi Maehashi |
# @version 2010-03-21 |
Param([String] $Domain, [String] $UserD, [String] $PasswordD, [Int32] $REBoot) |
Set-PSDebug-Strict |
functionConst([String] $name,$value) {Set-Variable-name $name-value $value-scope script -option Constant} |
functionUsage() { |
@' |
The syntax of this command is: |
NETDOM-JOIN -Domain:domain [-UserD:user] [-PasswordD:password] [-REBoot:Time in seconds] |
NETDOM-JOIN joins this computer to the domain. |
-Domain Specifies the domain which the machine should join |
-UserD User account used to make the connection with the domain |
specified by the -Domain argument |
-PasswordD Password of the user account specified by -UserD |
-REBoot Specifies that the machine should be shutdown and automatically |
rebooted after the Join has completed. The number of seconds |
before automatic shutdown must also be provided |
'@ |
} |
Const JOIN_DOMAIN 1 |
Const ACCT_CREATE 2 |
Const ACCT_DELETE 4 |
Const WIN9X_UPGRADE 16 |
Const DOMAIN_JOIN_IF_JOINED 32 |
Const JOIN_UNSECURE 64 |
Const MACHINE_PASSWORD_PASSED 128 |
Const DEFERRED_SPN_SET 256 |
Const INSTALL_INVOCATION 262144 |
if ($Domain-eq'') { |
Usage |
Exit |
} |
$result= |
(Get-WmiObject Win32_ComputerSystem).JoinDomainOrWorkgroup( |
$Domain, |
$PasswordD, |
$Domain+''+$UserD, |
$null, |
$JOIN_DOMAIN+$ACCT_CREATE |
) |
if ($result.ReturnValue-eq0) { |
Start-Sleep$REBoot |
Restart-Computer |
} else { |
'Failed to join this computer to the domain!' |
$result |
} |
Copy lines Copy permalink