# How to remove Windows service with PowerShell?

PowerShellMicrosoft TechnologiesSoftware & Coding

#### Powershell for beginners

15 Lectures 3.5 hours

#### Learning Task Automation using Windows PowerShell

35 Lectures 2.5 hours

#### The Complete PowerShell 7 course: Beginner To Advanced

Most Popular

145 Lectures 12.5 hours

We need to remove the window service named TestService using PowerShell. If you are using PowerShell 6.0 or above version, you can directly use a cmdlet Remove-Service command as shown below.

In this example, we have a service name called TestService.

Remove-Service Testservice -Confirm:\$false -Verbose

If you are using the PowerShell framework version (5.1 or below), you need to use the registry. Services are stored in the registry at the below location.

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\

To delete the service, we need to remove that service key with the command as shown below.

Get-Item HKLM:\SYSTEM\CurrentControlSet\Services\TestService | Remove-Item -Force -Verbose


Here we are using the Service name TestService and you need to reboot the server after running the above command.

Updated on 19-Feb-2021 13:13:54