次の方法で共有


Start-Service

Starts one or more stopped services.

構文

InputObject (既定)

Start-Service
    [-InputObject] <ServiceController[]>
    [-PassThru]
    [-Include <String[]>]
    [-Exclude <String[]>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

Default

Start-Service
    [-Name] <String[]>
    [-PassThru]
    [-Include <String[]>]
    [-Exclude <String[]>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

DisplayName

Start-Service
    -DisplayName <String[]>
    [-PassThru]
    [-Include <String[]>]
    [-Exclude <String[]>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

説明

This cmdlet is only available on the Windows platform.

The Start-Service cmdlet sends a start message to the Windows Service Controller for each of the specified services. If a service is already running, the message is ignored without error. You can specify the services by their service names or display names, or you can use the InputObject parameter to supply a service object that represents the services that you want to start.

Example 1: Start a service by using its name

This example starts the EventLog service on the local computer. The Name parameter identifies the service by its service name.

Start-Service -Name "eventlog"

Example 2: Display information without starting a service

This example shows what would occur if you started the services that have a display name that includes "remote".

Start-Service -DisplayName *remote* -WhatIf

The DisplayName parameter identifies the services by their display name instead of their service name. The WhatIf parameter causes the cmdlet to display what would happen when you run the command but does not make changes.

Example 3: Start a service and record the action in a text file

This example starts the Windows Management Instrumentation (WMI) service on the computer and adds a record of the action to the services.txt file.

$s = Get-Service wmi
Start-Service -InputObject $s -PassThru | Format-List >> services.txt

First we use Get-Service to get an object that represent the WMI service and store it in the $s variable. Next, we start the service. Without the PassThru parameter, Start-Service does not create any output. The pipeline operator (|) passes the object output by Start-Service to the Format-List cmdlet to format the object as a list of its properties. The append redirection operator (>>) redirects the output to the services.txt file. The output is added to the end of the existing file.

Example 4: Start a disabled service

This example shows how to start a service when the start type of the service is Disabled.

PS> Start-Service tlntsvr
Start-Service : Service 'Telnet (TlntSvr)' cannot be started due to the following error: Cannot
start service TlntSvr on computer '.'.
At line:1 char:14
+ Start-Service  <<<< tlntsvr

PS> Get-CimInstance Win32_Service | Where-Object Name -EQ "tlntsvr"
ExitCode  : 0
Name      : TlntSvr
ProcessId : 0
StartMode : Disabled
State     : Stopped
Status    : OK

PS> Set-Service tlntsvr -StartupType manual
PS> Start-Service tlntsvr

The first attempt to start the Telnet service (tlntsvr) fails. The Get-CimInstance command shows that the StartMode property of the Tlntsvr service is Disabled. The Set-Service cmdlet changes the start type to Manual. Now, we can resubmit the Start-Service command. This time, the command succeeds. To verify that the command succeeded, run Get-Service.

パラメーター

-Confirm

Prompts you for confirmation before running the cmdlet.

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

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

パラメーター セット

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

-DisplayName

Specifies the display names of the services to start. Wildcard characters are permitted.

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

型:

String[]

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

パラメーター セット

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

-Exclude

Specifies services that this cmdlet omits. The value of this parameter qualifies the Name parameter. Enter a name element or pattern, such as s*. Wildcard characters are permitted.

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

型:

String[]

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

パラメーター セット

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

-Include

Specifies services that this cmdlet starts. The value of this parameter qualifies the Name parameter. Enter a name element or pattern, such as s*. Wildcard characters are permitted.

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

型:

String[]

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

パラメーター セット

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

-InputObject

Specifies ServiceController objects representing the services to be started. Enter a variable that contains the objects, or type a command or expression that gets the objects.

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

型:

ServiceController[]

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

パラメーター セット

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

-Name

Specifies the service names for the service to be started.

The parameter name is optional. You can use Name or its alias, ServiceName, or you can omit the parameter name.

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

型:

String[]

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

パラメーター セット

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

-PassThru

Returns an object that represents the service. By default, this cmdlet does not generate any output.

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

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

パラメーター セット

(All)
配置:Named
必須:False
パイプラインからの値:False
プロパティ名別のパイプラインからの値:False
残りの引数からの値: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 service name to this cmdlet.

出力

None

By default, this cmdlet returns no output.

ServiceController

When you use the PassThru parameter, this cmdlet returns a ServiceController object representing the service.

メモ

PowerShell includes the following aliases for Start-Service:

  • Windows:
    • sasv

This cmdlet is only available on Windows platforms.

  • By default, only members of the Administrators group can start, stop, pause, resume, or restart a service. If you are a member of the Administrators group, you need to run Start-Service from an elevated PowerShell session. Use the Run as Administrator option to start PowerShell.
  • To find the service names and display names of the services on your system, type Get-Service. The service names appear in the Name column, and the display names appear in the DisplayName column.
  • You can start only the services that have a start type of Manual, Automatic, or Automatic (Delayed Start). You cannot start the services that have a start type of Disabled. If a Start-Service command fails with the message Cannot start service \<service-name\> on computer, use Get-CimInstance to find the start type of the service and, if you have to, use the Set-Service cmdlet to change the start type of the service.
  • Some services, such as Performance Logs and Alerts (SysmonLog) stop automatically if they have no work to do. When PowerShell starts a service that stops itself almost immediately, it displays the following message: Service \<display-name\> start failed.