47 lines
1.2 KiB
PowerShell
47 lines
1.2 KiB
PowerShell
|
|
<#
|
||
|
|
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
|