PowerShell script to start services in multiple computers from a file


Userlevel 7
Badge +2

Hi Folks,

 

I’m sharing a snippet of code which can help you in restarting some services in multiple remote computers:

$ServiceName = 'Veeam'
$Path = "$([System.Environment]::GetFolderPath("Desktop"))\Servers.txt"

Get-Content -Path $Path | ForEach-Object {
Write-Host "Processing $($_)"
Get-Service -Name "*$($ServiceName)*" -ComputerName $_ |
Where-Object { ($_.Status -eq 'Stopped') -and ($_.StartType -eq 'Automatic') } |
Start-Service -Verbose
}

 

Hope this can help you in performing the start and stop of the services that you may need.


2 comments

Userlevel 7
Badge +20

Thanks for sharing.  Adding to my PS library of scripts. 😎

Userlevel 7
Badge +2

Thanks for sharing.  Adding to my PS library of scripts. 😎

No problem @Chris.Childerhose 🙂, hope that helps.

Comment