Powershell Script to Restart a Service on Multiple Remote Computers

Powershell Script to Restart a Service on Multiple Remote Computers

If you use a computer, you must have encountered a problem where your device is irresponsive to your commands. This results in multiple services being stopped and not responding as well. We need to restart these services so they can perform again, but manually restarting them will take too much time.

A very quick method to restart a service on multiple remote computers is by using PowerShell. The method is very simple, but most people are unaware of it. We have shared all the information on the PowerShell script to restart a service.

What is PowerShell?

Every desktop, laptop, or computer has this automation platform installed, which helps users perform different actions with a single command. The manual methods can be too time-consuming. However, PowerShell can do it for you and save us time.

The PowerShell follows the command we give it, and that command has to be in a specific script that the device can understand. For instance, to restart any service on the computer, the PowerShell will follow a specific script.

Why Do We Need PowerShell to Restart a Service?

Most don’t know why they need to know the PowerShell script for restarting a service on their computer. This information can be helpful in many ways and save much of our time. The user often gets stuck on a single window and can’t get out of it, or they just can’t stop a service on their desktop. So, for such cases, we will need the PowerShell.

Some of the reasons we might need PowerShell are discussed below.

  • If any service on your computer fails because of a software bug or hardware failure, we can restart that service with the PowerShell.
  • After installing a new update on the computer, we need to restart the services on the device. PowerShell can do it automatically and faster.
  • All the services consume memory, which will take up too much space in the CPU, affecting its performance. To resolve this matter, we must restart the services using the PowerShell.

PowerShell Script to Restart a Service

The PowerShell script for restarting a service is not that difficult to remember or write. Also, for most of the services, the script will be pretty similar; the only difference will be the name of the service. One syntax that you have to remember is

Restart-Service –Name <Service Name>

In the above syntax, the service name will hold the name of the service you want to restart. Every service name has a different name you will use in the syntax. For instance, if you restart the Print Spooler service, you will write “Spooler” in the space next to the service name. The end product will be:

Restart-Service –Name Spooler -PassThru

Restart a Service on the Remote Computer

The steps to restart a service on a remote computer using PowerShell are a bit longer. We have multiple devices attached; hence, we need to give a more precise command to the PowerShell, which means a longer script.

We will use the remote computer parameter in our syntax while commanding on PowerShell. The script will be as follows.

  1. #Get the service in Remote Computer
  2. $Service = Get-Service -DisplayName “Print Spooler” –ComputerName “Remotes Computer Name”
  4. #Restart the Service
  5. Restart-Service –InputObject $Service –Verbose

Force Restart a Service

Sometimes, the service doesn’t restart even if you use the PowerShell script method. This is primarily because of your device’s software bug, which restricts or delays the command. To overcome this problem, you must force restart the service on your computer. The steps and scripts are shared below.

  • Open the PowerShell on your device from the start menu.
  • The syntax we will use for force restart is similar to the usual restart command but slightly different.
  • The force syntax for the Printer Spooler service will be Restart-Service –Name Spooler –Force.
  • The whole syntax will be the same for every service, especially the –Force, which will be there for every service. We will only change the service name.


PowerShell Script is a great way to restart a service on any device, including multiple remote computers. Along with saving a lot of time, this method also saves us from the headache of long manual procedures to restart a service. We have shared all the important information in this article, so read every point mentioned.


No comments yet. Why don’t you start the discussion?

Leave a Reply

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