A Windows service is a program that operates or runs in the background. These services help the developers to develop an executable program that operates in Windows sessions of its own. PowerShell has introduced several cmdlets to restart, start, or stop a specific service. These cmdlets include “Start-Service”, “Stop-Service”, or “Restart-Service”.
This blog will specifically provide information about the “Start-Service” cmdlet and other commands for Windows.
Learn PowerShell Start Service and Other Cmdlets for Windows
The list of cmdlets related to configuring Windows services is given below:
Cmdlet 1: Use the “Get-Service” Cmdlet to Get All Windows Services
The “Get-Service” cmdlet is responsible for getting the list of all Windows services, including the running and stopped ones.
To get the list of services in Windows, run the given cmdlet below:
It can be observed from the output that the list of all Windows services has been displayed.
Cmdlet 2: Start a Windows Service Using the “Start-Service” Cmdlet
The “Start-Service” cmdlet in PowerShell helps to start or initiates stopped services.
This example will demonstrate how to start a service in PowerShell:
According to the above code, first add the “Start-Service” cmdlet and then specify the service name to start:
Cmdlet 3: Stop a Windows Service Using the “Stop-Service” Cmdlet
To stop one or more running Windows services, the “Stop-Cmdlet” cmdlet is used.
Now, utilize the “Stop-Service” cmdlet to stop the specified service:
Cmdlet 4: Restart a Windows Service Using the “Restart-Service” Cmdlet
In case a Windows service is not running normally, then it needs to restart. To do so, the “Restart-Service” cmdlet is used.
For the mentioned purpose, execute the “Restart-Service” cmdlet with the service name:
That was all about starting, stopping, and restarting services through PowerShell.
PowerShell has several cmdlets related to managing or modifying Windows services. These cmdlets include “Get-Service”, “Stop-Service”, “Restart-Service”, or “Start-Service”. This write-up has provided a thorough guide related to the services related to “Start-Service” cmdlets and others in Windows.