Create Services_Check_Relance_si_KO.ps1
This commit is contained in:
parent
ebf759535e
commit
c23d99a752
22
POWERSHELL/Services_Check_Relance_si_KO.ps1
Normal file
22
POWERSHELL/Services_Check_Relance_si_KO.ps1
Normal 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'
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user