Wednesday, 6 February 2019

Start windows services on Multiple servers


Create Text file in your Desktop with Name server.txt and Service.txt and add the servers and Service accordingly.


$serverList  = Get-Content -Path $env:USERPROFILE\Desktop\Server.txt
$serviceList = Get-Content -Path $env:USERPROFILE\Desktop\Service.txt

ForEach ($server in $serverList)
{
    ForEach ($service in $serviceList)
    {
        Set-Service -ComputerName $server -Name $service -Status Running -StartupType Automatic
        Write-Host "service Started on server" -ForegroundColor Green
    }
}

No comments:

Post a Comment