DOMAIN — Join or leave a network domain, or display the current domain membership status.

Syntax:
DOMAIN domain /DS /L /OU:"path" /P:password /PDC /R /S:server /U:user /W /X /Y

/DSdelete the startup shortcut if successful
/Lleave; remove the computer from the domain
/OU:"path"Full RFC 1779 path of the organizational unit to join
/P:passwordpassword for the administrative account
/PDCuse the primary domain controller
/Rreboot if the operation is successful
/S:servername of the server (domain controller) to use
/U:useradministrative account to perform the operation
/Wjoin a workgroup, not a domain
/Xjoin even if computer is already part of a domain
/Ydo not prompt before joining or leaving
domainname of the domain to join or leave

If neither /L nor a domain is specified, the computer’s current domain membership status will be displayed.

Use /L to leave (“unjoin”) a domain. If you specify both /L and a domain, then the domain must match the computer’s current domain name. You can bypass this safety check by omitting the domain.

If you specify /P:* or if you give a user name without a password, you will be prompted to enter the password interactively.

By default, you will be prompted before joining or leaving a domain. /Y suppresses the prompt. If you specify /R, the computer will automatically reboot after a successful join or leave. /R and /Y together will reboot with no chance to cancel!

/OU allows you to specify the organizational unit within the domain you are joining. Give the full path, in RFC 1779 format, from the innermost to the outermost unit; for example, /OU:"ou=sales,ou=staff,dc=now99,dc=com". Alternatively, you can pass the path as \top-org\sub-org… (with a leading backslash) and the plugin will attempt to mangle it into RFC 1779 format for you automatically. Do not use this option unless you truly need to join a specific OU.

If /DS is specified and a domain join or leave succeeds, DOMAIN will delete the shortcut used to launch TCC or the current batch file. This option is not likely to be useful at the prompt! It’s intended for use in turnkey batch files to join a computer to a domain, on the theory that such a batch file will usually be called only once (after a workstation is freshly imaged).


This command calls the NetJoinDomain() API.


domain mydomain /u:mydomain\machodude /p:Seekr3t /r /y


Return codes:

0success
0syntax request via /?
1syntax or usage error
2the requested operation failed
if the operation succeeded and /R was specified, DOMAIN will not return