次の方法で共有


Remove-Service

Removes a Windows service.

構文

Name (既定)

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

InputObject

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.

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

パラメーター

-Confirm

Prompts you for confirmation before running the cmdlet.

パラメーターのプロパティ

型:SwitchParameter
規定値:False
ワイルドカードのサポート:False
DontShow:False
Aliases:cf

パラメーター セット

(All)
配置:Named
必須:False
パイプラインからの値:False
プロパティ名別のパイプラインからの値:False
残りの引数からの値:False

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

パラメーターのプロパティ

型:ServiceController
規定値:None
ワイルドカードのサポート:False
DontShow:False

パラメーター セット

InputObject
配置:Named
必須:False
パイプラインからの値:True
プロパティ名別のパイプラインからの値:False
残りの引数からの値:False

-Name

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

パラメーターのプロパティ

型:String
規定値:None
ワイルドカードのサポート:True
DontShow:False
Aliases:ServiceName, SN

パラメーター セット

Name
配置:0
必須:True
パイプラインからの値:True
プロパティ名別のパイプラインからの値:True
残りの引数からの値:False

-WhatIf

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

パラメーターのプロパティ

型:SwitchParameter
規定値:False
ワイルドカードのサポート:False
DontShow:False
Aliases:wi

パラメーター セット

(All)
配置:Named
必須:False
パイプラインからの値:False
プロパティ名別のパイプラインからの値:False
残りの引数からの値:False

CommonParameters

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

入力

ServiceController

You can pipe a service object to this cmdlet.

String

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.