This post will elaborate on the PowerShell “Get-Service” cmdlet.
How to Utilize/Use the “Get-Service” Command in PowerShell?
As stated above, the “Get-Service” cmdlet is utilized to get the available services in PowerShell including running and stopped ones.
Let’s move to the following examples for getting all services by executing the above-stated cmdlet.
Example 1: Use the “Get-Service” Cmdlet to Get all Services on the Computer
To retrieve all the services of the computer, execute the below-provided cmdlet:
Example 2: Use the “Get-Service” Cmdlet to Display Services That Include a Specified Search String
This example will display all t
To display all the services that include a particular search string that specified by the user, execute the “Get-Services” command along with the required parameter:
According to the above code:
- First, enter the “Get-Service” cmdlet, followed by the “-Displayname” parameter having the “*update*” value assigned.
- The string is enclosed within two wildcards so that it can be matched with the exact similar keyword from a search result:
Example 3: Use the “Get-Service” Cmdlet to Get Services That Begin with a Search String
To get the particular services that begin with the specified search string, use the “Get-Service ” cmdlet having a specific value assigned to it with the wildcard at the end. Putting an asterisk at the end of the string will help in finding the string that starts with the specific keyword:
Example 4: Use the “Get-Service” Cmdlet to Get Services That Begin with a Search String and an Exclusion
The below-stated command will search specific string and it will add an exclusion:
In the above-stated code:
- Enter the “Get-Service” cmdlet along with the “-Name” parameter having the “xbox*” value assigned to it.
- After that, specify the “-Exclude” parameter and assign the stated value to exclude it from the output:
Example 5: Use the “Get-Service” Cmdlet to Display Services That are Currently Active
To get and view all currently active services, use the provided command:
In the above-provided command:
- Specify the “Get-Service” cmdlet followed by the pipeline “|”.
- After that, add the “Where-Object” cmdlet and then specify the condition to get only the active services:
That’s all! We have provided the working of the “Get-Service” cmdlet in PowerShell.
Conclusion
In PowerShell, the “Get-Service” cmdlet is used for getting the list of the services operating on Windows. It gets the list of both running and stopped services. Moreover, it uses the parameters to get a personalized set of services. This post has explained the “Get-Service” cmdlet in detail.