{"id":9370,"date":"2016-06-20T13:20:08","date_gmt":"2016-06-20T12:20:08","guid":{"rendered":"https:\/\/myworldofit.net\/?p=9370"},"modified":"2016-06-20T13:22:06","modified_gmt":"2016-06-20T12:22:06","slug":"powershell-function-to-prevent-a-script-from-continuing-if-a-domain-controller-is-offline","status":"publish","type":"post","link":"https:\/\/myworldofit.net\/?p=9370","title":{"rendered":"Powershell Function to prevent a script from continuing if a Domain Controller is offline"},"content":{"rendered":"<p><a href=\"https:\/\/myworldofit.net\/wp-content\/uploads\/2016\/06\/Check-DCs.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignright size-medium wp-image-9374\" src=\"https:\/\/myworldofit.net\/wp-content\/uploads\/2016\/06\/Check-DCs-300x191.png\" alt=\"Check DCs\" width=\"300\" height=\"191\" srcset=\"https:\/\/myworldofit.net\/wp-content\/uploads\/2016\/06\/Check-DCs-300x191.png 300w, https:\/\/myworldofit.net\/wp-content\/uploads\/2016\/06\/Check-DCs-768x488.png 768w, https:\/\/myworldofit.net\/wp-content\/uploads\/2016\/06\/Check-DCs-1024x651.png 1024w, https:\/\/myworldofit.net\/wp-content\/uploads\/2016\/06\/Check-DCs.png 1170w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a>One of those monthly jobs that every SysAdmin will come across is good old Patch Tuesday; to help make Patch Tuesday a little more fun after all of the servers have been updated I use Hyper-V Replica (run by a PowerShell script) to shutdown each Virtual Machine and move it onto another host (ticks the box for the machine reboot component of Windows Updates and also tests our DR solution in one hit!).<br \/>\nHowever as both of my DCs are Virtual Machines I want to make sure that at least one DC is up at all times, to do that I have built a little PowerShell function (see below to download it within a zip file!) that is run before every migration to ensure that both DCs are up and running (along with the Network Policy Server service which is used to authenticate clients on the network (and so is very important!!)) before any migration happens.<\/p>\n<p>Hopefully this will help someone someday!<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/myworldofit.net\/wp-content\/plugins\/wp-downloadmanager\/images\/ext\/zip.gif\" alt=\"\" title=\"\" style=\"vertical-align: middle;\" \/>&nbsp;&nbsp;<strong><a href=\"https:\/\/myworldofit.net\/?dl_id=34\">See if DCs are up<\/a><\/strong> (905 bytes, 1,586 hits)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>One of those monthly jobs that every SysAdmin will come across is good old Patch Tuesday; to help make Patch Tuesday a little more fun after all of the servers have been updated I use Hyper-V Replica (run by a PowerShell script) to shutdown each Virtual Machine and move it onto another host (ticks the box for the machine reboot&#8230; <a class=\"read-more\" href=\"https:\/\/myworldofit.net\/?p=9370\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0,"footnotes":""},"categories":[11,20],"tags":[126,248,334],"series":[],"class_list":["post-9370","post","type-post","status-publish","format-standard","hentry","category-servers","category-software","tag-active-directory","tag-powershell","tag-test"],"_links":{"self":[{"href":"https:\/\/myworldofit.net\/index.php?rest_route=\/wp\/v2\/posts\/9370","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/myworldofit.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/myworldofit.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/myworldofit.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/myworldofit.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=9370"}],"version-history":[{"count":4,"href":"https:\/\/myworldofit.net\/index.php?rest_route=\/wp\/v2\/posts\/9370\/revisions"}],"predecessor-version":[{"id":9376,"href":"https:\/\/myworldofit.net\/index.php?rest_route=\/wp\/v2\/posts\/9370\/revisions\/9376"}],"wp:attachment":[{"href":"https:\/\/myworldofit.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=9370"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/myworldofit.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=9370"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/myworldofit.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=9370"},{"taxonomy":"series","embeddable":true,"href":"https:\/\/myworldofit.net\/index.php?rest_route=%2Fwp%2Fv2%2Fseries&post=9370"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}