Powershell

How to Use the Remove-Service (Microsoft.PowerShell.Management)?

PowerShell “Remove-Service” cmdlet is used to remove a Windows service from the operating system, registry, and also from service database. A Windows service is a background process or an activity used to perform various tasks, such as searching for items or monitoring the system. This cmdlet was first introduced in PowerShell 6.0 version, which means it is not supported on PowerShell 5.1.

This post will demonstrate the PowerShell “Remove-Service” cmdlet.

How to Use the Remove-Service (Microsoft.PowerShell.Management)?

The PowerShell cmdlet “Remove-Service” is responsible for deleting one or more services. Let’s check out the below-provided examples.

Example 1: Use the “Remove-Service” Cmdlet to Remove a Service

First, specify the “Remove-Service” cmdlet along with the “-Name” parameter and assign it the name of the service which needs to remove:

Remove-Service -Name "Service_1"

Example 2: Use the “Remove-Service” Cmdlet to Remove a Service Using its Display Name

Execute the given command to delete a service using the service display name:

Get-Service -DisplayName "Service_1" | Remove-Service

In the above-given command:

  • First, mention the “Get-Service” cmdlet along with the “-DisplayName” parameter and assign it the stated service name.
  • Next, add the “|” pipeline and specify the “Remove-Service” cmdlet at the end:

Example 3: Use the “Remove-Service” Cmdlet to Remove Multiple Services

In order to remove multiple services from Windows, simply assign multiple values to the “-DisplayName” parameter:

Get-Service -DisplayName "Service_1", "Service_2" | Remove-Service

You have learned about the “Remove-Service” cmdlet in PowerShell.

Conclusion

The “Remove-Service” cmdlet is utilized to remove single or multiple services from a registry or a service database. It is only supported on PowerShell version 6.0 and above. This post has illustrated the cmdlet “Remove-Service” with the help of various examples.

About the author

Muhammad Farhan

I am a Computer Science graduate and now a technical writer who loves to provide the easiest solutions to the most difficult problems related to Windows, Linux, and Web designing. My love for Computer Science emerges every day because of its ease in our everyday life.