Windows Service management through the control line is really a good approach when you want to manage plenty of services and perform day to day deportment like stop, start and restart

I think y'all would agree, If I say GUI is fun for entry-level simply when information technology comes to performing the job smartly and creating automation for efficiency. Command-line is your key

PowerShell has a lot of commands to help us manage the windows server ameliorate and create automation and do the tedious (or) repetitive tasks swiftly

In this article, we are going to see How to Manage Services from the Windows Command line using PowerShell. We are going to meet various examples of  How to List , Terminate, Start, Restart a Single Service or multiple Services.

To Manage the Services in Windows, We have a pack of Powershell commands and each does a unique task in the Windows Service Management. It helps us perform our day to day needs like Stopping, Starting, Restarting, Listing, Searching, etc

In this commodity, we are going to see various Windows Powershell commands  such as

  • Become-Sevice
  • Stop-Service
  • Start-Service
  • Where-Object
  • Restart-Service

Not just this, There are few more and look at the index to know what this article is packaged with

I am thrilled and I hope y'all are likewise. Let's march on.

Alphabetize

  1. How to Listing the Services  Windows Command Line
  2. How to List just Running or Stopped Services in PowerShell
  3. How to Listing a Service or Get Service past Name in Windows
  4. How to Search for the Service[s] by Status, DisplayName, Search String etc.
  5. How to Stop the Service[s] in Windows Command Line
  6. How to Start the Service[s] in Windows Control Line
  7. How to Restart the Service[southward] in Windows Control Line

How to Listing the Services in Windows Command Line

To List, all the Services in your Windows PC or Server, Perform the Following Steps

  1. Open PowerShell Final or PowerShell ISE as Administrator
  2. Blazon Get-Service in the Terminal

You lot would exist presented with all the available Services on the Windows Auto

The result would container 3 columns equally shown below, Status, Name,and DisplayName

You can search or List a Single or Multiple Services based on whatsoever of these columns, which nosotros will run into in upcoming sections on this article.

PS C:\Users\sarav>                  Get-Service                  Status   Name               DisplayName                  ------                  ----                  -----------                  Stopped  AarSvc_ba23f       Agent Activation Runtime_ba23f         Stopped  AJRouter           AllJoyn Router Service                 Stopped  ALG                Application Layer Gateway Service      Stopped  AppIDSvc           Awarding Identity                   Running  Appinfo            Application Information                Stopped  AppReadiness       App Readiness                          Running  AppXSvc            AppX Deployment Service (AppXSVC)      Running  AudioEndpointBu...                  Windows Audio Endpoint Builder         Running  Audiosrv           Windows Audio                          Stopped  autotimesvc        Cellular Time                          Stopped  AxInstSV           ActiveX Installer (AxInstSV)           Stopped  BcastDVRUserSer...                  GameDVR                  and                  Broadcast User Service_...                  Stopped  BDESVC             BitLocker Drive Encryption Service                

How to List only Running or Stopped Services in PowerShell

In this section we are going to run across how to list the windows services based on a Specific State they are in.

To Listing, Either only Running and Stopped Services, PowerShell Get-Service Command tin exist used along with one more Filtering control named Where-Object .

It acts like a grep of Linux and it does the job so perfect and precise

So to List Running or Stopped Services in Windows Control line you should do the following

  1. Open PowerShell Terminal or PowerShell ISE as Administrator
  2. Use i of the following command based on your requirement

To List Simply The Running Services

                  Get-Service                  |                  Where-Object                  {$_.Status                  -eq                  "Running"                  }

To Listing only the Stopped Services

                  Go-Service                  |                  Where-Object                  {$_.Condition                  -eq                  "Stopped"                  }                

In fact,  Yous tin can Use any of the Following State Value in place of Running or Stopped to get the Services in that Country.

Value Pregnant
ContinuePending The service has been paused and is well-nigh to continue.
Paused The service is paused.
PausePending The service is in the procedure of pausing.
Running The service is running.
StartPending The service is in the process of starting.
Stopped The service is non running.
StopPending The service is in the process of stopping.

For example, If yous would like to Get a Service which is in Paused State  then your command should be like this

                  Go-Service                  |                  Where-Object                  {$_.Status                  -eq                  "Paused"                  }                

How to List a Service or Get Service by Name in Windows

To List or to Get a Service by Proper noun you have to exist aware of the Name of the Service or at to the lowest degree a role of the Service proper name as we can use * wildcard to find the residue.

To List or to Become Service past Proper noun do the post-obit

  1. Open PowerShell Terminal or PowerShell ISE as Administrator
  2. Utilise the following Go-Service the command forth with a -Name (or) -DisplayName parameter

To List a Service named Jenkins I can use any of the following commands and Be informed that Service Proper noun is Case Insensitive

                  Become-Service                  -Name jenkins  (or)                  Become-Service                  -Proper noun jenkins  (or)                  Get-Service                  -DisplayName jenkins  (or)                  Get-Service                  -Name JEnKins  (or)                  Go-Service                  -DisplayName JEnKins  (or)                  Get-Service                  -Name  jen*s                

How to Search for the Service[s] by More Filters

Sometimes, Our requirement would not be simpler equally nosotros remember, It might get complicated when we go a requirement like

We might have to list (or) restart all the tomcat instances running on the server and exclude case which contains a Specific String in its proper name

Let'due south Suppose, that nosotros have a Windows Server withN number of Tomcat Services (instances) and they are named after their Surround name they vest to similar dev, uat etc. like Dev_Tomcat1, Test_Tomcat2, Uat_Tomcat4 then on.

Now to list merely the DEV and UAT instances and not Sit down nosotros would have to apply some more filters other than just Name or DisplayName

Here are some examples related to this type of scenario.

                  # All these examples made based on the presence of  # Environment Names `SIT` `UAT` `Dev` in the Service Name of # Service Display Name  # The Search is Past Default Example INSENSITIVE   # Find Tomcat Instances belong to Examination Environment                  Get-Service                  -DisplayName                  "*Tomcat*"                  -Include                  "*Test*"                  (or)                  Get-Service                  -DisplayName                  "*Tomcat*"                  -Include                  "*examination*"                  ----                  # Observe All Tomcat Instances EXCEPT the ones belong TEST Environment                  Get-Service                  -DisplayName                  "*Tomcat*"                  -Exclude                  "*Examination*"                  ----                  # You tin can also add together Status Filter into this command                  Go-Service                  -DisplayName                  "*Tomcat*"                  -Exclude                  "*Test*"|Where-Object                  {$_.Status                  -eq                  "Running"}                

How to Stop the Service[south] in Windows Command Line

We have so far seen, how to list the services in windows machine (PC or Server) using the Powershell control line.

Now we are going to meet, How to Cease the Service[s] in Windows PowerShell Control Line

Now allow us Split up this Part into ii as follows

  • How to Cease a Single Service past Name
  • How to Cease I or More Services matching the Query (or) Search term

Despite you lot are stopping a Single Service or Multiple Services. You have to first list the Services with Go-Service with necessary Filters like -Proper noun or Status etc.

One time the upshot is presented, With the help of pipe| symbol you pass all the services to an another Command called Stop-Service

Terminate-Service control is responsible to cease the service (or) Services

Simply put, to Terminate the Service or Services. You just demand to list it outset and make sure thats what you want to be stopped and then redirect information technology to Finish-Service with the assist of pipe

Here are some of Windows Stop Service Instance commands

                  # Simply Stop the Service named Jenkins                  Go-Service                  -Name Jenkins|Stop-Service                  ---                                      # Stop all Running Services                                    Become-Service|Where-Object                  {$_.Status                  -eq                  "Running"}|Stop-Service                                    ---                  # List and Stop All Running *Tomcat* Services                                    Get-Service                  -DisplayName                  "*Tomcat*"|Where-Object                  {$_.Status                  -eq                  "Running"}|Terminate-Service                                    ---                  # List and Cease All Running Tomcat Services,  # Just Production, No DEV, UAT, Sit down ( We Presume Display Name Contains the Environment Proper noun)                                                      Go-Service                  -DisplayName                  "*Tomcat*"                  -Exclude                  "*DEV*"                  "*Sit down*"                  "*UAT*"|Where-Object                  {$_.Status                  -eq                  "Running"}|Stop-Service                                  

How to Start the Service[due south] in Windows Control Line

At present nosotros are going to see, How to Start the Service[due south] in Windows PowerShell Control Line

Despite y'all are Starting a Single Service or Multiple Services. You have to outset listing the Services with Get-Service with necessary Filters similar -Name or Status etc.

Once the upshot is presented, With the assist of pipe| symbol y'all laissez passer all the services to some other Command called Outset-Service

Here are some of Windows Start Service from Command Line examples

                  # Simply Stop the Service named Jenkins                  Go-Servicec                  -Name Jenkins|                    Start-Service                                    ---                                      # Stop all Running Services                                    Get-Service|Where-Object                  {$_.Status                  -eq                  "Running"}|                    Start-Service                                                      ---                  # Listing and Stop All Running *Tomcat* Services                                    Get-Service                  -DisplayName                  "*Tomcat*"|Where-Object                  {$_.Status                  -eq                  "Running"}|                    Start-Service                                                      ---                  # List and Stop All Running Tomcat Services,  # Only Product, No DEV, UAT, SIT ( Nosotros Presume Display Name Contains the Surroundings Proper name)                                                      Go-Service                  -DisplayName                  "*Tomcat*"                  -Exclude                  "*DEV*"                  "*SIT*"                  "*UAT*"|Where-Object                  {$_.Condition                  -eq                  "Running"}|                    Outset-Service                                                    

How to Restart the Service[s] in Windows Command Line

We have only learned how to Stop and Outset the services, At present it is a time to learn How to Restart Service from Windows Command Line

To Restart windows Service Command Line do the following

  1. Open PowerShell Final or PowerShell ISE equally Administrator
  2. Employ the following Get-Service the command along with a -Name (or) -DisplayName parameter and List the Services y'all want to be restarted
  3. In the same Control add a pipe | symbol at the suffix along with a command Restart-Service

To Restart Windows Service from Command Line, Starting time we need to list the services that we desire to be restarted using Get-Service we tin can customize and Search for  the Services you desire usingGet-Service parameters likeProper name and DisplayName , Status etc

Once we take the list gear up with Single or Multiple Services that we want to restart.

We can utilise another control, Given dedicatedly to restart services named Restart-Service

In well-nigh cases, we would like to have more control on the Restart process, in such cases, yous tin effort to Stop and Start the services using Finish-Service and Start-Service commands rather directly using Restart-Service

Hither are few examples of How to restart the Service in Windows Command Line

                  # Merely Stop the Service named Jenkins                  Get-Servicec                  -Name Jenkins|                    Restart-Service                                    ---                                      # Stop all Running Services                                    Get-Service|Where-Object                  {$_.Condition                  -eq                  "Running"}|                    Restart-Service                                                      ---                  # List and Stop All Running *Tomcat* Services                                    Become-Service                  -DisplayName                  "*Tomcat*"|Where-Object                  {$_.Status                  -eq                  "Running"}|                    Restart-Service                                                      ---                  # List and Stop All Running Tomcat Services,  # Only Production, No DEV, UAT, Sit down ( We Presume Display Proper noun Contains the Environment Name)                                                      Go-Service                  -DisplayName                  "*Tomcat*"                  -Exclude                  "*DEV*"                  "*Sit down*"                  "*UAT*"|Where-Object                  {$_.Status                  -eq                  "Running"}|                    Restart-Service                                                    

Then This is how Windows PowerShell commands aid us to manage the Windows services from Control line, We learned how to List, finish, start and restart windows services from control line

With this command line, We can terminate, start, restart  Multiple services at once in majority that's what I like the most about it.

If you have any questions for me. Delight feel free to annotate

Charge per unit this article [ratings] Share it with your friends if yous find it worth

Thanks
Sarav AK

Buy Me a Coffee at ko-fi.com

Follow us onFacebook orTwitter
For more applied videos and tutorials. Subscribe to our aqueduct
Find me on Linkedin My Profile
For whatever Consultation or to hire the states [electronic mail protected]
If y'all like this article. Bear witness your Support! Buy me a Coffee.

Signup for Exclusive "Subscriber-just" Content