{"id":2695,"date":"2018-11-02T23:44:08","date_gmt":"2018-11-02T23:44:08","guid":{"rendered":"http:\/\/microsoftgeek.com\/?p=2695"},"modified":"2018-11-02T23:45:36","modified_gmt":"2018-11-02T23:45:36","slug":"how-to-add-computers-to-a-domain-using-powershell","status":"publish","type":"post","link":"https:\/\/microsoftgeek.com\/?p=2695","title":{"rendered":"How to Add Computers to a Domain Using PowerShell"},"content":{"rendered":"<h2 class=\"user-content_title title -h2 \">Performing a Domain Join Using PowerShell<\/h2>\n<p class=\"user-content_text text \">Once you\u2019ve established correct DNS resolution for the domain name, start a PowerShell prompt with local administrative privileges.<\/p>\n<ul class=\"user-content_text text -list -unordered \">\n<li class=\"text_list-item \">Press the Windows key to switch to the Start menu, type\u00a0<b>PowerShell<\/b>\u00a0and press\u00a0<b>CTRL+SHIFT+ENTER<\/b>. If prompted, enter a local administrator username and password, or give consent to run PowerShell.<\/li>\n<li class=\"text_list-item \">In the PowerShell prompt, type\u00a0<span style=\"color: #99cc00;\"><b>add-computer \u2013domainname ad.contoso.com -Credential AD\\adminuser -restart \u2013force<\/b><\/span>\u00a0and press\u00a0<b>Enter<\/b>. Enter a password for the domain administrator account when prompted.<\/li>\n<\/ul>\n<p class=\"user-content_text text \">The PC should now restart and be joined to the domain once it has restarted.<\/p>\n<figure id=\"attachment_48181\" class=\"wp-caption alignnone\"><img class=\"_js size-large wp-image-48181\" sizes=\"(max-width: 590px) 100vw, 590px\" srcset=\"https:\/\/www.petri.com\/wp-content\/uploads\/sites\/3\/Figure1151-590x70.jpg 590w, https:\/\/www.petri.com\/wp-content\/uploads\/sites\/3\/Figure1151-300x36.jpg 300w, https:\/\/www.petri.com\/wp-content\/uploads\/sites\/3\/Figure1151-600x71.jpg 600w, https:\/\/www.petri.com\/wp-content\/uploads\/sites\/3\/Figure1151.jpg 708w\" alt=\"Add a computer to a domain using PowerShell\" width=\"590\" height=\"70\" \/><figcaption class=\"wp-caption-text\"><em>Add a computer to a domain using PowerShell.<\/em><\/figcaption><\/figure>\n<h2 class=\"user-content_title title -h2 \">Join Multiple PCs to a Domain<\/h2>\n<p class=\"user-content_text text \">You can add more than one computer to the domain, either by using names from a text file or listing them in the command line as a comma-delimited list. You can use the<span style=\"color: #99cc00;\">\u00a0<strong>\u2013computername<\/strong><\/span>\u00a0parameter even if PowerShell Remoting isn\u2019t enabled on the computers listed in the command line.<\/p>\n<ul class=\"user-content_text text -list -unordered \">\n<li class=\"text_list-item \">In a PowerShell command prompt, type\u00a0<span style=\"color: #99cc00;\"><b>add-computer -computername srvcore01, srvcore02 -domainname ad.contoso.com \u2013credential<\/b>\u00a0<b>AD\\adminuser -restart \u2013force\u00a0<\/b><\/span>and press\u00a0<b>Enter<\/b>.<\/li>\n<li class=\"text_list-item \">Type a password for the domain administrator account when prompted.<\/li>\n<\/ul>\n<p class=\"user-content_text text \">The command above adds\u00a0<span style=\"color: #99cc00;\"><i>srvcore01<\/i>\u00a0<\/span>and\u00a0<span style=\"color: #99cc00;\"><i>srvcore02<\/i>\u00a0<\/span>to <span style=\"color: #99cc00;\">ad.contoso.com<\/span> domain. The account used to run the PowerShell prompt would need permission to connect and join both servers to the domain. You could also specify a list of servers in a text file (<span style=\"color: #99cc00;\">servers.txt<\/span>) as follows:<\/p>\n<p class=\"user-content_text text \"><span style=\"color: #99cc00;\"><b>add-computer -computername (get-content servers.txt) -domainname ad.contoso.com \u2013credential<\/b>\u00a0<b>AD\\adminuser -restart \u2013force<\/b><\/span><\/p>\n<p class=\"user-content_text text \">In the above command,\u00a0<span style=\"color: #99cc00;\"><i>servers.txt<\/i>\u00a0<\/span>would need to be located in the PowerShell working directory.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Performing a Domain Join Using PowerShell Once you\u2019ve established correct DNS resolution for the domain name, start a PowerShell prompt with local administrative privileges. Press the Windows key to switch to the Start menu, type\u00a0PowerShell\u00a0and press\u00a0CTRL+SHIFT+ENTER. If prompted, enter a local administrator username and password, or give consent to run PowerShell. In the PowerShell prompt, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[59],"tags":[],"class_list":["post-2695","post","type-post","status-publish","format-standard","hentry","category-powershell"],"_links":{"self":[{"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=\/wp\/v2\/posts\/2695","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2695"}],"version-history":[{"count":3,"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=\/wp\/v2\/posts\/2695\/revisions"}],"predecessor-version":[{"id":2698,"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=\/wp\/v2\/posts\/2695\/revisions\/2698"}],"wp:attachment":[{"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2695"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2695"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2695"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}