Powershell script to restart services on multiple computers

Windows operating system runs many services in background and they all are managed through services.msc console. Few application issues can be fixed by restarting their respective service.

We can restart service of single computer by manually logging in to the computer using remote desktop connection, whereas if you experience issues with multiple computers then logging-in to each and every computer manually through remote desktop will consume more time.

To resolve this issue we use powershell scripts, using the powershell script we can restart windows service for bulk computers all at once and it saves huge amount of manual effort and time.

Powershell script to restart service on multiple computers:

We use get-content to get the list of computers and assigned it to the variable $Computers.

Since we deal with multiple computers here we used ForEach loop to execute the commands for each and every computers.

We use Get- Service followed by service name to find and fetch the service and passed the output to restart-service cmdlet using pipeline operator to restart the service. we used this script to restart BITS service on multiple computers

Combine all the individual scripts that are listed to a single script with simple function as mentioned below:

Copy the script to the notepad file and save it with .ps1 extension and call the script from command prompt to execute.

 

Hope this article helps to solves your query on how to restart service on multiple computers. execute this script at your own risk and always try to execute the script in test environment before implementing in production as we do not provide any guarantee or warranty.

Add a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.