Create Services_Check_Relance_si_KO.ps1

This commit is contained in:
Demonic 2023-01-19 15:48:10 +01:00 committed by GitHub
parent ebf759535e
commit c23d99a752
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -0,0 +1,22 @@
$services = @("service1","service2")
For($i=0;$i -lt $services.Length;$i++)
{
$ServiceName = "$($services[$i])"
$getService = Get-Service -Name $ServiceName
while ($getService.Status -ne 'Running')
{
Start-Service $ServiceName
write-host $getService.status
write-host 'Service starting'
Start-Sleep -seconds 60
$getService.Refresh()
if ($getService.Status -eq 'Running')
{
Write-Host 'Service is now Running'
}
}
}