adding computers to a domain using command line

I want a  command to add computers to my  Windows Active directory domain
Ashar KallumpurathuAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Marwan OsmanCommented:
one computer or a list of PCs?
Marwan OsmanCommented:
Add-Computer -DomainName yourdomain -Restart
Marwan OsmanCommented:
run it from the PC which you want to add it to the domain
The 7 Worst Nightmares of a Sysadmin

Fear not! To defend your business’ IT systems we’re going to shine a light on the seven most sinister terrors that haunt sysadmins. That way you can be sure there’s nothing in your stack waiting to go bump in the night.

Marwan OsmanCommented:
Ashar KallumpurathuAuthor Commented:
Will you  Show me an example
Marwan OsmanCommented:
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?
Ashar KallumpurathuAuthor Commented:
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
Marwan OsmanCommented:
run : Add-Computer -DomainName lab.com

then restart the pc manually
Ashar KallumpurathuAuthor Commented:
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
Marwan OsmanCommented:
try Add-Computer -DomainName Dascase
Ashar KallumpurathuAuthor Commented:
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
Marwan OsmanCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ashar KallumpurathuAuthor Commented:
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
Marwan OsmanCommented:
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.
Ashar KallumpurathuAuthor Commented:
can u answer me the other question i asked you about manualy joining a computer to  a domain
Seth SimmonsSr. Systems AdministratorCommented:
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".
Marwan OsmanCommented:
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.
Marwan OsmanCommented:
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.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Server 2008

From novice to tech pro — start learning today.