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:
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:
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:
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.