Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #-----------------------------------------------------------------------
- #
- #
- # This script automates the checks that are required after the red
- # servers have been rebooted on the 1st Tuesday of the month. This is
- # not a fully automated script and some user interaction is required.
- # The checks are done server by server and they vary, so pauses have
- # been added to facilitate administrator interaction.
- #
- # This script is designed to be ran from <box>, where the various
- # dependancies required by the script are installed. This script should
- # be ran as <user> from an administrative Powershell prompt. A profile
- # for powershell has been set up to load the required snap-ins to run
- # this script.
- #
- # TODO: Create an MMC shortcut to <server> ADUC - dependencies: RSAT
- # TODO: Get RSAT Tools installed
- #-----------------------------------------------------------------------
- write ------------------------------------------------------------------
- write "Running through post reboot checks for Red Servers 1st Tuesday"
- write ------------------------------------------------------------------
- write ------------------------------------------------------------------
- write "`nChecking ServerA`n"
- write ------------------------------------------------------------------
- # Call a previously created VNC shortcut to the server
- # Start dsa.msc locally pointed towards ServerA
- Invoke-Item -Path "<Path to VNC shortcut>"
- Start-Process “C:\Windows\System32\mmc.exe” -WorkingDirectory $PSHOME -ArgumentList "dsa.msc"
- 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"
- Start-Sleep -Seconds 10
- $message = 'ServerA'
- $question = 'Have all of the checks been completed succesfully for this server?'
- $choices = New-Object Collections.ObjectModel.Collection[Management.Automation.Host.ChoiceDescription]
- $choices.Add((New-Object Management.Automation.Host.ChoiceDescription -ArgumentList '&Yes'))
- $choices.Add((New-Object Management.Automation.Host.ChoiceDescription -ArgumentList '&No'))
- $decision = $Host.UI.PromptForChoice($message, $question, $choices, 1)
- if ($decision -eq 0) {
- Write-Host 'Checks completed successfully'
- } else {
- Write-Host 'Checks have not completed successfully'
- }
- write ------------------------------------------------------------------
- write ------------------------------------------------------------------
- write "`nChecking ServerB`n"
- write ------------------------------------------------------------------
- # Call a previously created VNC shortcut to the server
- # Start Hyper-V administration console locally pointed towards <server>
- Invoke-Item -Path "<Path to VNC Shortcut>"
- Start-Process "%windir%\system32\HyperVTools.msc"
- 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"
- Start-Sleep -Seconds 10
- $message = 'ServerB'
- $question = 'Have all of the checks been completed succesfully for this server?'
- $choices = New-Object Collections.ObjectModel.Collection[Management.Automation.Host.ChoiceDescription]
- $choices.Add((New-Object Management.Automation.Host.ChoiceDescription -ArgumentList '&Yes'))
- $choices.Add((New-Object Management.Automation.Host.ChoiceDescription -ArgumentList '&No'))
- $decision = $Host.UI.PromptForChoice($message, $question, $choices, 1)
- if ($decision -eq 0) {
- Write-Host 'Checks completed successfully'
- } else {
- Write-Host 'Checks have not completed successfully'
- }
- write ------------------------------------------------------------------
- # Call a previously created VNC shortcut to the server
- # Call a previosuly created ADUC MMC shortcut pointed to <server>
- write ------------------------------------------------------------------
- write "`nChecking ServerC`n"
- write ------------------------------------------------------------------
- Invoke-Item -Path "<Patch to VNC>"
- 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"
- Start-Sleep -Seconds 10
- $message = 'ServerC'
- $question = 'Have all of the checks been completed succesfully for this server?'
- $choices = New-Object Collections.ObjectModel.Collection[Management.Automation.Host.ChoiceDescription]
- $choices.Add((New-Object Management.Automation.Host.ChoiceDescription -ArgumentList '&Yes'))
- $choices.Add((New-Object Management.Automation.Host.ChoiceDescription -ArgumentList '&No'))
- $decision = $Host.UI.PromptForChoice($message, $question, $choices, 1)
- if ($decision -eq 0) {
- Write-Host 'Checks completed successfully'
- } else {
- Write-Host 'Checks have not completed successfully'
- }
- write ------------------------------------------------------------------
- # Call a previously created VNC shortcut to the server
- # Call a previosuly created ADUC MMC shortcut pointed to <server>
- write ------------------------------------------------------------------
- write "`nChecking ServerD`n"
- write ------------------------------------------------------------------
- Invoke-Item -Path "<Shortcut to VNC>"
- 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"
- Start-Sleep -Seconds 10
- $message = 'ServerC'
- $question = 'Have all of the checks been completed succesfully for this server?'
- $choices = New-Object Collections.ObjectModel.Collection[Management.Automation.Host.ChoiceDescription]
- $choices.Add((New-Object Management.Automation.Host.ChoiceDescription -ArgumentList '&Yes'))
- $choices.Add((New-Object Management.Automation.Host.ChoiceDescription -ArgumentList '&No'))
- $decision = $Host.UI.PromptForChoice($message, $question, $choices, 1)
- if ($decision -eq 0) {
- Write-Host 'Checks completed successfully'
- } else {
- Write-Host 'Checks have not completed successfully'
- }
- write ------------------------------------------------------------------
- # Call a previosuly created VNC shortcut to the server
- # Start iexplore.exe and browse to specific internal webstie
- write ------------------------------------------------------------------
- write "`nChecking ServerE`n"
- write ------------------------------------------------------------------
- Invoke-Item -Path "<path to VNC shortcut>"
- $IE=new-object -com internetexplorer.application
- $IE.navigate2("<website>")
- $IE.visible=$true
- 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"
- Start-Sleep -Seconds 10
- $message = 'ServerE'
- $question = 'Have all of the checks been completed succesfully for this server?'
- $choices = New-Object Collections.ObjectModel.Collection[Management.Automation.Host.ChoiceDescription]
- $choices.Add((New-Object Management.Automation.Host.ChoiceDescription -ArgumentList '&Yes'))
- $choices.Add((New-Object Management.Automation.Host.ChoiceDescription -ArgumentList '&No'))
- $decision = $Host.UI.PromptForChoice($message, $question, $choices, 1)
- if ($decision -eq 0) {
- Write-Host 'Checks completed successfully'
- } else {
- Write-Host 'Checks have not completed successfully'
- }
- write ------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement