start services using powersehll on multiple servers

HuuM 46 Reputation points
2022-08-26T15:29:59.113+00:00

i have application installed on windows and services can be started from services utility,

there are multiple servers,
i need touse poweshell script to start services on all servers with one script execution.

kindly advise script template, for example sql services/

Windows for business | Windows Server | User experience | PowerShell
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Dillon Silzer 57,831 Reputation points Volunteer Moderator
    2022-08-26T16:08:17.893+00:00

    Hi @KShahzad-8722

    You can use the PowerShell command:

    Start-Service -Name "eventlog"

    https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.management/start-service?view=powershell-7.2#example-1-start-a-service-by-using-its-name

    ---------------------------------------

    If this is helpful please accept answer.

    0 comments No comments

  2. Andreas Baumgarten 123.7K Reputation points MVP Volunteer Moderator
    2022-08-26T16:24:55.993+00:00

    Hi @KShahzad-8722 ,

    if you want to start a service on remote computers Start-Service might not help/work. Start-Service will start the service on the local computer where the cmdlet is executed.

    But maybe you like to try this:

    $servers = "server1", "server2"  
    $servers | ForEach-Object {  
        Get-Service -Name wuauserv -ComputerName $_ | Set-Service -Status Running  
    }  
    

    ----------

    (If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

    Regards
    Andreas Baumgarten

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.