Link to home
Start Free TrialLog in
Avatar of Ashar Kallumpurathu
Ashar KallumpurathuFlag for United States of America

asked on

adding computers to a domain using command line

I want a  command to add computers to my  Windows Active directory domain
Avatar of Marwan Osman
Marwan Osman
Flag of Lebanon image

one computer or a list of PCs?
Add-Computer -DomainName yourdomain -Restart
run it from the PC which you want to add it to the domain
Avatar of Ashar Kallumpurathu

ASKER

Will you  Show me an example
suppose you want to add the PC named testpc to your domain named lab.com

logon to testpc, open the powershell as administrator, type: Add-Computer -DomainName lab.com -Restart

the pc is added to the domain and will restart automatically, is it clear?
its showing the  following errors when typing this command
Add-Computer : A parameter cannot be found that matches parameter name 'Restart'.
At line:1 char:46
+ Add-Computer -DomainName Dascase.com -Restart <<<<
    + CategoryInfo          : InvalidArgument: (:) [Add-Computer], ParameterBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.AddComputerCommand
 how to resolve this error
run : Add-Computer -DomainName lab.com

then restart the pc manually
Add-Computer : This command cannot be executed on target computer('SRV1') due to following error: The specified domain
either does not exist or could not be contacted.
At line:1 char:13
+ Add-Computer <<<<  -DomainName Dascase.com
    + CategoryInfo          : InvalidOperation: (SRV1:String) [Add-Computer], InvalidOperationException
    + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands.AddComputerCommand
Now its Showing the above error
try Add-Computer -DomainName Dascase
Add-Computer : This command cannot be executed on target computer('SRV1') due to following error: Unknown error (0xa8b
.
At line:1 char:13
+ Add-Computer <<<<  -DomainName Dascase
    + CategoryInfo          : InvalidOperation: (SRV1:String) [Add-Computer], InvalidOperationException
    + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands.AddComputerCommand
now its showing this error
ASKER CERTIFIED SOLUTION
Avatar of Marwan Osman
Marwan Osman
Flag of Lebanon image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Add-Computer : This command cannot be executed on target computer('SRV1') due to following error: The specified domain
either does not exist or could not be contacted.
At line:1 char:13
+ Add-Computer <<<<  -DomainName Dascase.com -credential dascase\administrator
    + CategoryInfo          : InvalidOperation: (SRV1:String) [Add-Computer], InvalidOperationException
    + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands.AddComputerCommand
now its showing this error
I tried and it works with me, this is the correct cmd, it seems you have a problem contacting your domain.

since you asked about a command and the command is provided to you, this question must be closed, and you can ask in a separate question on how to troubleshoot the problem.
can u answer me the other question i asked you about manualy joining a computer to  a domain
Avatar of Seth Simmons
I've requested that this question be deleted for the following reason:

The question has either no comments or not enough useful information to be called an "answer".
he asked about a cmd to join a PC to the domain and an example and I replied him with the correct comment after testing it to join a PC to windows 2008 domain, below is my comment:

Add-Computer -DomainName Dascase.com -credential dascase\administrator

when you run this cmd, it will ask you to type the password, try and inform me please


so this is the correct answer to his question, and since he received an error, this is another issue and need troubleshooting, he can ask about it in a separate question.
the correct answer is in the comment which has the ID 40809783, the asker only asks about a cmd to add a computer to a domain and I provided it to him after successfully test it.