add ps1 script to safely restart services and WAIT until complete before proceeding
This commit is contained in:
24
build-support/wait-to-restart-service.ps1
Normal file
24
build-support/wait-to-restart-service.ps1
Normal file
@@ -0,0 +1,24 @@
|
||||
[CmdletBinding()]
|
||||
Param(
|
||||
[Parameter(Mandatory=$True)]
|
||||
[string]$serviceName
|
||||
)
|
||||
write-output 'Attempting to restart service $serviceName'
|
||||
|
||||
$svc = get-service $serviceName
|
||||
|
||||
write-output 'Initial service status:'
|
||||
write-output $svc
|
||||
|
||||
if($svc.Status -ne 'Running') {
|
||||
start-service $svc
|
||||
$svc.WaitForStatus('Running', '00:01:00')
|
||||
}
|
||||
else {
|
||||
$svc.WaitForStatus('Running', '00:01:00')
|
||||
restart-service $svc
|
||||
$svc.WaitForStatus('Running', '00:01:00')
|
||||
}
|
||||
|
||||
write-output 'Final service status:'
|
||||
write-output $svc
|
||||
Reference in New Issue
Block a user