Powershell script how to start service | how to start stopped service | script to monitor service
HTML-код
- Опубликовано: 27 окт 2024
- Script:
$serviceName = 'Spooler'
$serviceData = Get-Service -Name $serviceName
If($serviceData.Status -ne 'Running')
{
write-host "service is not running.." -ForegroundColor Red
Start-Service -Name $serviceName
}
else
{
Write-Host "Service is in running state. Hence no action required." -ForegroundColor Green
}