Advertisement
Ed213

[PS] Post Reboot Checks

Jun 23rd, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.49 KB | None | 0 0
  1. #-----------------------------------------------------------------------
  2. #
  3. #
  4. # This script automates the checks that are required after the red
  5. # servers have been rebooted on the 1st Tuesday of the month. This is
  6. # not a fully automated script and some user interaction is required.
  7. # The checks are done server by server and they vary, so pauses have
  8. # been added to facilitate administrator interaction.
  9. #
  10. # This script is designed to be ran from <box>, where the various
  11. # dependancies required by the script are installed. This script should
  12. # be ran as <user> from an administrative Powershell prompt. A profile
  13. # for powershell has been set up to load the required snap-ins to run
  14. # this script.
  15. #
  16. # TODO: Create an MMC shortcut to <server> ADUC - dependencies: RSAT
  17. # TODO: Get RSAT Tools installed
  18. #-----------------------------------------------------------------------
  19.  
  20. write ------------------------------------------------------------------
  21. write "Running through post reboot checks for Red Servers 1st Tuesday"
  22. write ------------------------------------------------------------------
  23.  
  24. write ------------------------------------------------------------------
  25. write "`nChecking ServerA`n"
  26. write ------------------------------------------------------------------
  27.  
  28. # Call a previously created VNC shortcut to the server
  29. # Start dsa.msc locally pointed towards ServerA
  30.  
  31. Invoke-Item -Path "<Path to VNC shortcut>"
  32. Start-Process “C:\Windows\System32\mmc.exe” -WorkingDirectory $PSHOME -ArgumentList "dsa.msc"
  33. write-host "`nIf VNC prompted for credentials without error & Active Directory Users and Computers console appeared & connected okay: checks have completed successfully.`n" -foreground "Yellow"
  34. Start-Sleep -Seconds 10
  35. $message = 'ServerA'
  36. $question = 'Have all of the checks been completed succesfully for this server?'
  37.  
  38. $choices = New-Object Collections.ObjectModel.Collection[Management.Automation.Host.ChoiceDescription]
  39. $choices.Add((New-Object Management.Automation.Host.ChoiceDescription -ArgumentList '&Yes'))
  40. $choices.Add((New-Object Management.Automation.Host.ChoiceDescription -ArgumentList '&No'))
  41.  
  42. $decision = $Host.UI.PromptForChoice($message, $question, $choices, 1)
  43. if ($decision -eq 0) {
  44. Write-Host 'Checks completed successfully'
  45. } else {
  46. Write-Host 'Checks have not completed successfully'
  47. }
  48. write ------------------------------------------------------------------
  49.  
  50. write ------------------------------------------------------------------
  51. write "`nChecking ServerB`n"
  52. write ------------------------------------------------------------------
  53.  
  54. # Call a previously created VNC shortcut to the server
  55. # Start Hyper-V administration console locally pointed towards <server>
  56.  
  57. Invoke-Item -Path "<Path to VNC Shortcut>"
  58. Start-Process "%windir%\system32\HyperVTools.msc"
  59. write-host "`nIf VNC prompted for credentials without error, Hyper-V administration console starts & all local VMs are running and accessible: checks have completed successfully.`n" -foreground "Yellow"
  60. Start-Sleep -Seconds 10
  61. $message = 'ServerB'
  62. $question = 'Have all of the checks been completed succesfully for this server?'
  63.  
  64. $choices = New-Object Collections.ObjectModel.Collection[Management.Automation.Host.ChoiceDescription]
  65. $choices.Add((New-Object Management.Automation.Host.ChoiceDescription -ArgumentList '&Yes'))
  66. $choices.Add((New-Object Management.Automation.Host.ChoiceDescription -ArgumentList '&No'))
  67.  
  68. $decision = $Host.UI.PromptForChoice($message, $question, $choices, 1)
  69. if ($decision -eq 0) {
  70. Write-Host 'Checks completed successfully'
  71. } else {
  72. Write-Host 'Checks have not completed successfully'
  73. }
  74. write ------------------------------------------------------------------
  75.  
  76. # Call a previously created VNC shortcut to the server
  77. # Call a previosuly created ADUC MMC shortcut pointed to <server>
  78.  
  79. write ------------------------------------------------------------------
  80. write "`nChecking ServerC`n"
  81. write ------------------------------------------------------------------
  82.  
  83. Invoke-Item -Path "<Patch to VNC>"
  84. write-host "`nIf VNC prompted for credentials without error & Active Directory Users and Computers console connected to <servername> appeared without error: checks have completed successfully.`n" -foreground "Yellow"
  85. Start-Sleep -Seconds 10
  86. $message = 'ServerC'
  87. $question = 'Have all of the checks been completed succesfully for this server?'
  88.  
  89. $choices = New-Object Collections.ObjectModel.Collection[Management.Automation.Host.ChoiceDescription]
  90. $choices.Add((New-Object Management.Automation.Host.ChoiceDescription -ArgumentList '&Yes'))
  91. $choices.Add((New-Object Management.Automation.Host.ChoiceDescription -ArgumentList '&No'))
  92.  
  93. $decision = $Host.UI.PromptForChoice($message, $question, $choices, 1)
  94. if ($decision -eq 0) {
  95. Write-Host 'Checks completed successfully'
  96. } else {
  97. Write-Host 'Checks have not completed successfully'
  98. }
  99. write ------------------------------------------------------------------
  100.  
  101. # Call a previously created VNC shortcut to the server
  102. # Call a previosuly created ADUC MMC shortcut pointed to <server>
  103.  
  104. write ------------------------------------------------------------------
  105. write "`nChecking ServerD`n"
  106. write ------------------------------------------------------------------
  107. Invoke-Item -Path "<Shortcut to VNC>"
  108. write-host "`nIf VNC prompted for credentials without error & Active Directory Users and Computers console connected to <servername> appeared without error: checks have completed successfully.`n" -foreground "Yellow"
  109. Start-Sleep -Seconds 10
  110. $message = 'ServerC'
  111. $question = 'Have all of the checks been completed succesfully for this server?'
  112.  
  113. $choices = New-Object Collections.ObjectModel.Collection[Management.Automation.Host.ChoiceDescription]
  114. $choices.Add((New-Object Management.Automation.Host.ChoiceDescription -ArgumentList '&Yes'))
  115. $choices.Add((New-Object Management.Automation.Host.ChoiceDescription -ArgumentList '&No'))
  116.  
  117. $decision = $Host.UI.PromptForChoice($message, $question, $choices, 1)
  118. if ($decision -eq 0) {
  119. Write-Host 'Checks completed successfully'
  120. } else {
  121. Write-Host 'Checks have not completed successfully'
  122. }
  123. write ------------------------------------------------------------------
  124.  
  125. # Call a previosuly created VNC shortcut to the server
  126. # Start iexplore.exe and browse to specific internal webstie
  127.  
  128. write ------------------------------------------------------------------
  129. write "`nChecking ServerE`n"
  130. write ------------------------------------------------------------------
  131. Invoke-Item -Path "<path to VNC shortcut>"
  132. $IE=new-object -com internetexplorer.application
  133. $IE.navigate2("<website>")
  134. $IE.visible=$true
  135. write-host "`nIf VNC prompted for credentials without error & the web page showing the vault logo with an error on user permissions appears: checks have completed successfully.`n" -foreground "Yellow"
  136. Start-Sleep -Seconds 10
  137. $message = 'ServerE'
  138. $question = 'Have all of the checks been completed succesfully for this server?'
  139.  
  140. $choices = New-Object Collections.ObjectModel.Collection[Management.Automation.Host.ChoiceDescription]
  141. $choices.Add((New-Object Management.Automation.Host.ChoiceDescription -ArgumentList '&Yes'))
  142. $choices.Add((New-Object Management.Automation.Host.ChoiceDescription -ArgumentList '&No'))
  143.  
  144. $decision = $Host.UI.PromptForChoice($message, $question, $choices, 1)
  145. if ($decision -eq 0) {
  146. Write-Host 'Checks completed successfully'
  147. } else {
  148. Write-Host 'Checks have not completed successfully'
  149. }
  150. write ------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement