Remove-Service

Removes a Windows service.

Syntax

Remove-Service
      [-Name] <String>
      [-WhatIf]
      [-Confirm]
      [<CommonParameters>]
Remove-Service
      [-InputObject] <ServiceController[]>
      [-WhatIf]
      [-Confirm]
      [<CommonParameters>]

Description

The Remove-Service cmdlet removes a Windows service in the registry and in the service database.

Examples

Example 1: Remove a service

PS C:\> Remove-Service -Name "TestService"

This command removes a service named TestService.

Example 2: Remove a service using the display name

PS C:\> Get-Service -DisplayName "Test Service" | Remove-Service

This command creates a service named TestService. The command uses Get-Service to get an object that represents the TestService service using the display name. The pipeline operator (|) pipes the object to Remove-Service , which removes the service.

Required Parameters

-InputObject

Specifies ServiceController objects that represent the services to stop. Enter a variable that contains the objects, or type a command or expression that gets the objects.

Type: ServiceController[]
Position: 1
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False
-Name

Specifies the service names of the services to stop. Wildcard characters are permitted.

Type: String[]
Aliases: ServiceName
Position: 1
Default value: None
Accept pipeline input: True (ByPropertyName, ByValue)
Accept wildcard characters: False

Optional Parameters

-Confirm

Prompts you for confirmation before running the cmdlet.

Type: SwitchParameter
Aliases: cf
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Type: SwitchParameter
Aliases: wi
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

Inputs

System.ServiceProcess.ServiceController, System.String

You can pipe a service object or a string that contains the name of a service to this cmdlet.

Outputs

None

This cmdlet does not return any output.

Notes

  • To run this cmdlet on Windows Vista and later versions of the Windows operating system, start Windows PowerShell by using the Run as administrator option.