Remove-Service
Removes a Windows service.
Remove-Service
[-Name] <String>
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Remove-Service
[-InputObject <ServiceController>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
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.
This removes a service named TestService.
Remove-Service -Name "TestService"
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
Prompts you for confirmation before running the cmdlet.
Type: | SwitchParameter |
Aliases: | cf |
Position: | Named |
Default value: | False |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
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: | ServiceController |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Specifies the service names of the services to remove. Wildcard characters are permitted.
Type: | String |
Aliases: | ServiceName, SN |
Position: | 0 |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | True |
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Type: | SwitchParameter |
Aliases: | wi |
Position: | Named |
Default value: | False |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
You can pipe a service object to this cmdlet.
You can pipe a string that contains the name of a service to this cmdlet.
None
This cmdlet returns no output.
This cmdlet is only available on Windows platforms.
To run this cmdlet, start PowerShell by using the Run as administrator option.
PowerShell feedback
PowerShell is an open source project. Select a link to provide feedback: