how to join computer to domain through powershell

匿名 (未验证) 提交于 2019-12-03 03:06:01

问题:

I have just done a fresh installation of windows 7 professional, and I would like to join my pc to domain through powershell but getting some error here is the code which I am using

Add-Computer -ComputerName HMD-PC002 -DomainName mydomain -Credential      mydomain\Administrator  Add-Computer : Computer 'HMD-PC002' failed to join domain 'mydomain' from its current   workgroup 'WORKGROUP' with following error message: Unknown error (0xa8b). At C:\Users\HMDPC002\Desktop\add-pc_to_Domain.ps1:8 char:1 + Add-Computer -ComputerName HMD-PC002 -DomainName mydomain -Credential mydomain\A ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo          : OperationStopped: (HMD-PC002:String) [Add-Computer],    InvalidOperationException + FullyQualifiedErrorId :    FailToJoinDomainFromWorkgroup,Microsoft.PowerShell.Commands.AddComputerComma 

回答1:

There was an easy solution to this, i didnt configure my dns server i had to change it manually and after populating the two field i ran the following script and it worked

Add-Computer -DomainName mydomain -Credential mydomain\Administrator -Restart 

However i want powershell to change the dns setting i will ask this in a separate question



回答2:

What i did before joining a server to domain:

1) Check the connectivity between DC and Server. Ping the domain controller. It should ping if both are on same subnet, else domain can't be joined.

2) Ran this powershell command:

PS C:\Windows\system32> add-computer domain.com -Credential domain\administrator WARNING: The changes will take effect after you restart the computer SERVERNAME.



回答3:

As specified by you that it is already working script and from the error code and upon giving search it looks to be a problem with AD, please refer to the below link and try and see if it works by IP as suggested here.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!