diff --git a/Services Scripts/Service - Take Control Services - Restart.ps1 b/Services Scripts/Service - Take Control Services - Restart.ps1 new file mode 100644 index 0000000..60fef01 --- /dev/null +++ b/Services Scripts/Service - Take Control Services - Restart.ps1 @@ -0,0 +1,47 @@ +<# +Author: Gabe Kerntke +Date: 05-02-2024 + +.Synopsis +Script to restart the Take Control services after we do a DR test + +.Modified +2024-05-02 (GabeK) - Original script created +#> + +#Variables +$ServiceName = "BASupportExpressStandaloneService_N_Central" +$ServiceName1 = "BASupportExpressSrvcUpdater_N_Central" + +#Region Functions + +#Stop Services +Function StopServices { + Stop-Service $ServiceName -Force -WarningAction:SilentlyContinue | Out-Null + Stop-Service $ServiceName1 -Force | Out-Null + Start-Sleep 5 + If ((Get-Service $ServiceName).Status -eq "Stopped" -and (Get-Service $ServiceName1).Status -eq "Stopped" ) { + Write-Host "Services were stopped successfully" + StartServices + } + Else { + Write-Host "One more more services failed to stop. Exiting script." + } +} + +#Start Services +Function StartServices { + Start-Service $ServiceName + Start-Service $ServiceName1 + Start-Sleep 5 + Get-ServiceStatus +} + +Function Get-ServiceStatus { + If ((Get-Service $ServiceName).Status -eq "Running" -and (Get-Service $ServiceName1).Status -eq "Running" ) { + Write-Host "Services were restarted successfully" + } +} + +#Region Script Start +StopServices \ No newline at end of file