Skip to content
Permalink
main
Switch branches/tags
Go to file
 
 
Cannot retrieve contributors at this time
external help file Locale Module Name ms.date online version schema title
Microsoft.PowerShell.Commands.Management.dll-Help.xml
en-US
Microsoft.PowerShell.Management
06/21/2021
2.0.0
Remove-Service

Remove-Service

SYNOPSIS

Removes a Windows service.

SYNTAX

Name (Default)

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

InputObject

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

DESCRIPTION

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

The Remove-Service cmdlet was introduced in PowerShell 6.0.

EXAMPLES

Example 1: Remove a service

This removes a service named TestService.

Remove-Service -Name "TestService"

Example 2: Remove a service using the display name

This example removes 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.

Get-Service -DisplayName "Test Service" | Remove-Service

PARAMETERS

-InputObject

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

The InputObject parameter doesn't enumerate collections. If a collection is passed, an error is thrown. When working with collections, pipe the input to enumerate the values.

Type: System.ServiceProcess.ServiceController
Parameter Sets: InputObject
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False

-Name

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

Type: System.String
Parameter Sets: Name
Aliases: ServiceName, SN

Required: True
Position: 0
Default value: None
Accept pipeline input: True (ByPropertyName, ByValue)
Accept wildcard characters: True

-Confirm

Prompts you for confirmation before running the cmdlet.

Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases: cf

Required: False
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: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases: wi

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

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

This cmdlet is only available on Windows platforms.

To run this cmdlet, start PowerShell by using the Run as administrator option.

RELATED LINKS

Get-Service

Restart-Service

Resume-Service

Set-Service

Start-Service

Stop-Service

Suspend-Service