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 actions similar finish, commencement and restart

I think you would concur, If I say GUI is fun for entry-level merely 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 united states manage the windows server amend and create automation and practice the boring (or) repetitive tasks swiftly

In this commodity, we are going to see How to Manage Services from the Windows Command line using PowerShell. Nosotros are going to see various examples of  How to List , Cease, Offset, 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 job in the Windows Service Management. Information technology helps united states perform our solar day to solar day needs like Stopping, Starting, Restarting, Listing, Searching, etc

In this article, we are going to run across various Windows Powershell commands  such as

  • Get-Sevice
  • Cease-Service
  • Start-Service
  • Where-Object
  • Restart-Service

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

I am thrilled and I hope yous are too. Let'southward march on.

Index

  1. How to List the Services  Windows Command Line
  2. How to List but Running or Stopped Services in PowerShell
  3. How to Listing a Service or Get Service by Proper name in Windows
  4. How to Search for the Service[due south] by Status, DisplayName, Search Cord etc.
  5. How to Stop the Service[s] in Windows Command Line
  6. How to Get-go the Service[s] in Windows Command Line
  7. How to Restart the Service[s] in Windows Command Line

How to Listing the Services in Windows Command Line

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

  1. Open PowerShell Concluding or PowerShell ISE as Administrator
  2. Type Go-Service in the Terminal

Y'all would exist presented with all the available Services on the Windows Machine

The event would container three columns as shown below, Status, Name,and DisplayName

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

PS C:\Users\sarav>                  Become-Service                  Status   Name               DisplayName                  ------                  ----                  -----------                  Stopped  AarSvc_ba23f       Amanuensis 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 Architect         Running  Audiosrv           Windows Sound                          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 just Running or Stopped Services in PowerShell

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

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

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

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

  1. Open PowerShell Final or PowerShell ISE as Administrator
  2. Utilize one of the following command based on your requirement

To Listing Only The Running Services

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

To List only the Stopped Services

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

In fact,  You can Apply whatsoever of the Following Land Value in place of Running or Stopped to get the Services in that State.

Value Pregnant
ContinuePending The service has been paused and is about to continue.
Paused The service is paused.
PausePending The service is in the process of pausing.
Running The service is running.
StartPending The service is in the process of starting.
Stopped The service is not running.
StopPending The service is in the process of stopping.

For example, If you would like to Become a Service which is in Paused Country  then your command should exist like this

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

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

To Listing or to Get a Service by Proper noun you have to be enlightened of the Name of the Service or at to the lowest degree a part of the Service name as we can apply * wildcard to observe the rest.

To List or to Go Service by Name practice the post-obit

  1. Open up PowerShell Final or PowerShell ISE as Administrator
  2. Employ the post-obit Get-Service the control along with a -Proper noun (or) -DisplayName parameter

To List a Service named Jenkins I tin can employ whatever of the following commands and Be informed that Service Proper name is Case Insensitive

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

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

Sometimes, Our requirement would not be simpler as nosotros think, Information technology might get complicated when nosotros go a requirement like

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

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

Now to list simply the DEV and UAT instances and not Sit down we would have to use some more than filters other than merely Name or DisplayName

Here are some examples related to this type of scenario.

                  # All these examples fabricated based on the presence of  # Surround Names `Sit` `UAT` `Dev` in the Service Name of # Service Display Name  # The Search is By Default Instance INSENSITIVE   # Find Tomcat Instances belong to Examination Environment                  Go-Service                  -DisplayName                  "*Tomcat*"                  -Include                  "*Exam*"                  (or)                  Become-Service                  -DisplayName                  "*Tomcat*"                  -Include                  "*tEst*"                  ----                  # Find All Tomcat Instances EXCEPT the ones belong Test Environment                  Get-Service                  -DisplayName                  "*Tomcat*"                  -Exclude                  "*Test*"                  ----                  # You tin too add STATUS Filter into this command                  Become-Service                  -DisplayName                  "*Tomcat*"                  -Exclude                  "*Test*"|Where-Object                  {$_.Status                  -eq                  "Running"}                

How to Finish the Service[due south] in Windows Command Line

We have and then far seen, how to list the services in windows automobile (PC or Server) using the Powershell command line.

At present we are going to meet, How to Stop the Service[south] in Windows PowerShell Control Line

At present let us Split this Part into two as follows

  • How to Stop a Single Service by Name
  • How to Stop One or More Services matching the Query (or) Search term

Despite you are stopping a Single Service or Multiple Services. Yous accept to kickoff listing the Services with Go-Service with necessary Filters like -Name or Status etc.

Once the result is presented, With the help of piping| symbol you pass all the services to an another Command called Finish-Service

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

Simply put, to Stop the Service or Services. Y'all simply need to list it get-go and make sure thats what you want to be stopped and then redirect it to Terminate-Service with the assistance of pipe

Here are some of Windows Stop Service Example commands

                  # But Stop the Service named Jenkins                  Get-Service                  -Name Jenkins|Finish-Service                  ---                                      # End all Running Services                                    Become-Service|Where-Object                  {$_.Status                  -eq                  "Running"}|Stop-Service                                    ---                  # Listing and End All Running *Tomcat* Services                                    Get-Service                  -DisplayName                  "*Tomcat*"|Where-Object                  {$_.Condition                  -eq                  "Running"}|End-Service                                    ---                  # List and Cease All Running Tomcat Services,  # Only Production, No DEV, UAT, SIT ( We Assume Display Name Contains the Environment Name)                                                      Get-Service                  -DisplayName                  "*Tomcat*"                  -Exclude                  "*DEV*"                  "*Sit down*"                  "*UAT*"|Where-Object                  {$_.Condition                  -eq                  "Running"}|Stop-Service                                  

How to Beginning the Service[s] in Windows Control Line

At present we are going to see, How to First the Service[southward] in Windows PowerShell Command Line

Despite you are Starting a Single Service or Multiple Services. Y'all accept to first list the Services with Get-Service with necessary Filters like -Name or Status etc.

In one case the effect is presented, With the assistance of pipe| symbol you pass all the services to another Command chosen Kickoff-Service

Here are some of Windows Start Service from Command Line examples

                  # But Stop the Service named Jenkins                  Get-Servicec                  -Name Jenkins|                    Commencement-Service                                    ---                                      # Stop all Running Services                                    Get-Service|Where-Object                  {$_.Status                  -eq                  "Running"}|                    Start-Service                                                      ---                  # List and Terminate All Running *Tomcat* Services                                    Get-Service                  -DisplayName                  "*Tomcat*"|Where-Object                  {$_.Status                  -eq                  "Running"}|                    Offset-Service                                                      ---                  # List and Cease All Running Tomcat Services,  # Only Product, No DEV, UAT, SIT ( We Assume Display Proper name Contains the Environment Name)                                                      Go-Service                  -DisplayName                  "*Tomcat*"                  -Exclude                  "*DEV*"                  "*Sit*"                  "*UAT*"|Where-Object                  {$_.Status                  -eq                  "Running"}|                    Commencement-Service                                                    

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

We accept just learned how to Finish and Start the services, At present it is a time to acquire How to Restart Service from Windows Command Line

To Restart windows Service Control Line do the post-obit

  1. Open up PowerShell Terminal or PowerShell ISE as Administrator
  2. Use the following Get-Service the command along with a -Proper noun (or) -DisplayName parameter and List the Services you desire to be restarted
  3. In the aforementioned Control add together a piping | symbol at the suffix along with a control Restart-Service

To Restart Windows Service from Command Line, First we need to listing the services that we want to be restarted using Get-Service we tin customize and Search for  the Services you want usingGet-Service parameters likeName and DisplayName , Condition etc

One time we take the list fix with Single or Multiple Services that we want to restart.

We can utilize some other control, Given dedicatedly to restart services named Restart-Service

In almost cases, we would like to take more control on the Restart process, in such cases, yous tin can attempt to Stop and Kickoff the services using Finish-Service and Offset-Service commands rather directly using Restart-Service

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

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

So This is how Windows PowerShell commands assistance u.s. to manage the Windows services from Command line, We learned how to List, terminate, start and restart windows services from command line

With this command line, Nosotros can stop, start, restart  Multiple services at once in bulk that's what I like the well-nigh about it.

If you have any questions for me. Delight feel gratuitous to comment

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

Cheers
Sarav AK

Buy Me a Coffee at ko-fi.com

Follow usa onFacebook orTwitter
For more practical videos and tutorials. Subscribe to our channel
Find me on Linkedin My Profile
For any Consultation or to hire us [electronic mail protected]
If you like this article. Show your Back up! Purchase me a Coffee.

Signup for Exclusive "Subscriber-only" Content