Skip to main content

PowerShell script to start services in multiple computers from a file


vAdmin
Forum|alt.badge.img+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

Chris.Childerhose
Forum|alt.badge.img+21
  • Veeam Legend, Veeam Vanguard
  • 8502 comments
  • November 30, 2022

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


vAdmin
Forum|alt.badge.img+2
  • Author
  • Influencer
  • 168 comments
  • November 30, 2022
Chris.Childerhose wrote:

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

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