$path = “C:\GreyAgents.txt”
$srvlist = Get-Content “$path”
$serviceName = “HealthService”
Foreach ($srv in $srvlist)
{
Write-host “Greyagents” : “$srv”
Invoke-Command -ComputerName $srv -Scriptblock{ Stop-Service -ServiceName ‘HealthService’}
Start-sleep -Seconds 10
Invoke-Command -ComputerName $srv -Scriptblock{ Start-Service -ServiceName ‘HealthService’}
Write-host “Health Service ReStarted Successfully”
}