{"id":3007,"date":"2020-08-27T23:41:12","date_gmt":"2020-08-28T04:41:12","guid":{"rendered":"http:\/\/microsoftgeek.com\/?p=3007"},"modified":"2020-08-27T23:41:12","modified_gmt":"2020-08-28T04:41:12","slug":"join-linux-to-active-directory-with-powershell-core","status":"publish","type":"post","link":"https:\/\/microsoftgeek.com\/?p=3007","title":{"rendered":"Join Linux to Active Directory with PowerShell Core"},"content":{"rendered":"\n<p>There are many possibilities for using PowerShell on non-Windows platforms now and today my mind was pondering how to use it to join Linux servers to Active Directory. So, I created a small little function that automates some of this called\u00a0<strong>Join-LinuxToAD<\/strong>. Keep in mind\u00a0I tested this only on CentOS 7.<\/p>\n\n\n\n<p>The script does the following:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Ensures you can lookup the domain with nslookup<\/li><li>Ensures Samba and other dependencies are installed via yum<\/li><li>Uses the&nbsp;<strong>realm<\/strong>&nbsp;command to join the local server to an Active Directory domain<\/li><\/ul>\n\n\n\n<p>While this is not totally automated, it does at least some of the work for you. I use\u00a0<strong>$LASTEXITCODE<\/strong>\u00a0has a way to do some error checking in the script.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/microsoftgeek.com\/wp-content\/uploads\/2020\/08\/linux1-1-1024x604.png\" alt=\"\" class=\"wp-image-3010\" width=\"1450\" height=\"855\" srcset=\"https:\/\/microsoftgeek.com\/wp-content\/uploads\/2020\/08\/linux1-1-1024x604.png 1024w, https:\/\/microsoftgeek.com\/wp-content\/uploads\/2020\/08\/linux1-1-300x177.png 300w, https:\/\/microsoftgeek.com\/wp-content\/uploads\/2020\/08\/linux1-1-768x453.png 768w, https:\/\/microsoftgeek.com\/wp-content\/uploads\/2020\/08\/linux1-1-1536x906.png 1536w, https:\/\/microsoftgeek.com\/wp-content\/uploads\/2020\/08\/linux1-1.png 1538w\" sizes=\"auto, (max-width: 1450px) 100vw, 1450px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>Now lets run it:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"884\" height=\"83\" src=\"http:\/\/microsoftgeek.com\/wp-content\/uploads\/2020\/08\/linux2.png\" alt=\"\" class=\"wp-image-3008\" srcset=\"https:\/\/microsoftgeek.com\/wp-content\/uploads\/2020\/08\/linux2.png 884w, https:\/\/microsoftgeek.com\/wp-content\/uploads\/2020\/08\/linux2-300x28.png 300w, https:\/\/microsoftgeek.com\/wp-content\/uploads\/2020\/08\/linux2-768x72.png 768w\" sizes=\"auto, (max-width: 884px) 100vw, 884px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>There are many possibilities for using PowerShell on non-Windows platforms now and today my mind was pondering how to use it to join Linux servers to Active Directory. So, I created a small little function that automates some of this called\u00a0Join-LinuxToAD. Keep in mind\u00a0I tested this only on CentOS 7. The script does the following: [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[42,13,59],"tags":[],"class_list":["post-3007","post","type-post","status-publish","format-standard","hentry","category-ad","category-linux","category-powershell"],"_links":{"self":[{"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=\/wp\/v2\/posts\/3007","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=3007"}],"version-history":[{"count":4,"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=\/wp\/v2\/posts\/3007\/revisions"}],"predecessor-version":[{"id":3014,"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=\/wp\/v2\/posts\/3007\/revisions\/3014"}],"wp:attachment":[{"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3007"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3007"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3007"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}