{"id":599,"date":"2015-08-26T10:29:24","date_gmt":"2015-08-26T10:29:24","guid":{"rendered":"http:\/\/giraffeit.com\/?p=599"},"modified":"2018-04-19T10:14:26","modified_gmt":"2018-04-19T10:14:26","slug":"pskdcstopstart","status":"publish","type":"post","link":"https:\/\/giraffeit.com\/index.php\/2015\/08\/26\/pskdcstopstart\/","title":{"rendered":"Powershell stop and restart multiple KDC"},"content":{"rendered":"<p><strong>Powershell<\/strong> stop and restart multiple <strong>KDC<\/strong><\/p>\n<p>We had a requirement to stop and restart the KDC on multiple remote DCs.<\/p>\n<p>Rather than go around each one , we wrote a script .<\/p>\n<pre class=\"lang:ps decode:true \" >function DateAndTimeLog\r\n{\r\nGet-date\r\n}\r\nfunction testIf\r\n{\r\nIf (Test-Connection -comp $dc -count 1 -quiet) {\r\n$dc+\" is online! \"\r\n}\r\nElse {\r\n$dc+\" is offline, moving to next Domain Controller\"\r\ncontinue;\r\n}\r\n\r\n}\r\nfunction SlowItDown\r\n{\r\nStart-Sleep -s 5\r\n}\r\n\r\nfunction MessageStop\r\n{\r\nWrite-Host \"stopping the KDC on $DC \"\r\nWrite-Output \"stopping the KDC on $DC \"\r\n}\r\n\r\nfunction MessageStart\r\n{\r\nWrite-Host \"now restarting the KDC on $DC \"\r\nWrite-Output \"now restarting the KDC on $DC \"\r\nWrite-Output \"finished process\"\r\nWrite-Output \" ------------------ \"\r\n}\r\n\r\n$File =\"C:DCResults.txt\"\r\n$DCsinOurDomain= Get-ADDomainController -Filter *\r\n\r\nForEach($DC in $DCsinOurDomain.HostName){\r\nDateAndTimeLog | Out-File $File -Append\r\ntestif | ft | Out-File $File -Append\r\n(Get-WmiObject Win32_Service -filter \"name='kdc'\" -ComputerName $DC).StopService()\r\nMessageStop | Out-File $File -Append\r\nSlowItDown\r\n(Get-WmiObject Win32_Service -filter \"name='kdc'\" -ComputerName $DC).StartService()\r\nMessageStart | Out-File $File -Append\r\n\r\n}<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Powershell stop and restart multiple KDC We had a requirement to stop and restart the KDC on multiple remote DCs. Rather than go around each one , we wrote a script . function DateAndTimeLog { Get-date } function testIf { If (Test-Connection -comp $dc -count 1 -quiet) { $dc+&#8221; is online! &#8221; } Else { &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/giraffeit.com\/index.php\/2015\/08\/26\/pskdcstopstart\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Powershell stop and restart multiple KDC&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":206,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[],"class_list":["post-599","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-bog"],"_links":{"self":[{"href":"https:\/\/giraffeit.com\/index.php\/wp-json\/wp\/v2\/posts\/599","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/giraffeit.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/giraffeit.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/giraffeit.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/giraffeit.com\/index.php\/wp-json\/wp\/v2\/comments?post=599"}],"version-history":[{"count":2,"href":"https:\/\/giraffeit.com\/index.php\/wp-json\/wp\/v2\/posts\/599\/revisions"}],"predecessor-version":[{"id":761,"href":"https:\/\/giraffeit.com\/index.php\/wp-json\/wp\/v2\/posts\/599\/revisions\/761"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/giraffeit.com\/index.php\/wp-json\/wp\/v2\/media\/206"}],"wp:attachment":[{"href":"https:\/\/giraffeit.com\/index.php\/wp-json\/wp\/v2\/media?parent=599"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/giraffeit.com\/index.php\/wp-json\/wp\/v2\/categories?post=599"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/giraffeit.com\/index.php\/wp-json\/wp\/v2\/tags?post=599"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}