As IT Professional it's very important to have the right tools for managing system services and automating tasks that it's possible. PowerShell can efficiently perform theses tasks. With PowerShell, you can simplify complex operations and automate tasks your day routine
Today I will explain how can manage Windows Services with PowerShell.
Because you will need to know where to find the Display Name of the Service let's see how can find it.
- Open the Services
- Double click on the Specific service that you want and you will see the Display Name
How to restart a Service with PowerShell
A very common scenario is to restart a Service because something it's not going very well. So you want to be sure that the service is working as expected.
Restart-Service -Name <Service Name>
For example let's resstart the AnyDesk Service
Restart-Service -Name AnyDesk
However you can restart the Service with the Display Name instead of Service Name.
Be carefully to include the Display Name in quotes if it's more than one word
For example
Restart-Service -Display Name "AnyDesk Service"
With the Restart-Service you can use the -PassThru option that returns an object that represent the status of the Service.
Let's see the difference
Restart-Service -Display Name "AnyDesk Service" -PassThru
How to stop a Service PowerShell
You can start a Windows Service with the following simple command
Stop-Service -Name <Service Name>
For example let's stop the AnyDesk Service
Stop-Service -Name AnyDesk
However you can stop the Service with the Display Name instead of Service Name.
Be carefully to include the Display Name in quotes if it's more than one word.
For example
Stop-Service -Display Name "AnyDesk Service"
With the Stop-Service you can use the -PassThru option that returns an object that represent the status of the Service.
Let's see the difference
Stop-Service -Display Name "AnyDesk Service" -PassThru
How to start a Service with PowerShell
The command to start a Service with PowerShell is similar with the Stop-Service.
Start-Service -Name <Service Name>
For example let's start the AnyDesk Service
Start-Service -Name AnyDesk
However you can start the Service with the Display Name instead of Service Name.
Be carefully to include the Display Name in quotes if it's more than one word.
For example
Start-Service -Display Name "AnyDesk Service"
With the Start-Service you can use the -PassThru option that returns an object that represent the status of the Service.
Let's see the difference
Start-Service -Display Name "AnyDesk Service" -PassThru
How to list services with PowerShell
Another one usefully command that can use with PowerShell is the Get-Service that list all the Services of the Windows.
Let's see how can use it
Get-Service
However if you want to find a specific service it's very difficult to search in this list.
In this case you can use the command
Get-Service -Name any*
Basic commands that can help you when you need to work with PowerShell.
Let's see you in the next article.