Export (0) Print
Expand All

Start-Service

Updated: May 8, 2014

Applies To: Windows PowerShell 4.0

Start-Service

Starts one or more stopped services.

Aliases

The following abbreviations are aliases for this cmdlet:

  • sasv

Syntax

Parameter Set: InputObject
Start-Service [-InputObject] <ServiceController[]> [-Exclude <String[]> ] [-Include <String[]> ] [-PassThru] [ <CommonParameters>]

Parameter Set: Default
Start-Service [-Name] <String[]> [-Exclude <String[]> ] [-Include <String[]> ] [-PassThru] [ <CommonParameters>]

Parameter Set: DisplayName
Start-Service -DisplayName <String[]> [-Exclude <String[]> ] [-Include <String[]> ] [-PassThru] [ <CommonParameters>]




Detailed Description

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 representing the services that you want to start.

Parameters

-DisplayName<String[]>

Specifies the display names of the services to be started. Wildcards are permitted.


Aliases

none

Required?

true

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

true

-Exclude<String[]>

Omits the specified services. The value of this parameter qualifies the Name parameter. Enter a name element or pattern, such as "s*". Wildcards are permitted.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

true

-Include<String[]>

Starts only the specified services. The value of this parameter qualifies the Name parameter. Enter a name element or pattern, such as "s*". Wildcards are permitted.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

true

-InputObject<ServiceController[]>

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.


Aliases

none

Required?

true

Position?

1

Default Value

none

Accept Pipeline Input?

true (ByValue)

Accept Wildcard Characters?

false

-Name<String[]>

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.


Aliases

none

Required?

true

Position?

1

Default Value

none

Accept Pipeline Input?

true (ByPropertyName, ByValue)

Accept Wildcard Characters?

false

-PassThru

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


Aliases

none

Required?

false

Position?

named

Default Value

False

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

<CommonParameters>

This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, and -OutVariable. For more information, see  about_CommonParameters (http://go.microsoft.com/fwlink/p/?LinkID=113216).

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

  • System.ServiceProcess.ServiceController, System.String

    You can pipe objects that represent the services or strings that contain the service names to Start-Service.


Outputs

The output type is the type of the objects that the cmdlet emits.

  • None or System.ServiceProcess.ServiceController

    When you use the PassThru parameter, Start-Service generates a System.ServiceProcess.ServiceController object representing the service. Otherwise, this cmdlet does not generate any output.


Notes

  • You can also refer to Start-Service by its built-in alias, "sasv". For more information, see about_Aliases.

    Start-Service can control services only when the current user has permission to do so. If a command does not work correctly, you might not have the required permissions.

    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" or "Automatic". You cannot start the services with a start type of "Disabled". If a Start-Service command fails with the message "Cannot start service <service-name> on computer," use a Get-WmiObject command to find the start type of the service and, if necessary, use a Set-Service command 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 Windows PowerShell starts a service that stops itself almost immediately, it displays the following message: "Service <display-name> start failed."

Examples

-------------------------- EXAMPLE 1 --------------------------

This command starts the EventLog service on the local computer. It uses the Name parameter to identify the service by its service name.


PS C:\> start-service -name eventlog

-------------------------- EXAMPLE 2 --------------------------

This command tells what would happen if you started the services with a display name that includes "remote". It uses the DisplayName parameter to specify the services by their display name instead of by their service name. And, it uses the WhatIf parameter to tell what would happen if the command were executed instead of executing the command.


PS C:\> start-service -displayname *remote* -whatif

-------------------------- EXAMPLE 3 --------------------------

These commands start the Windows Management Instrumentation (WMI) service on the computer and add a record of the action to the services.txt file. The first command uses the Get-Service cmdlet to get an object representing the WMI service and store it in the $s variable.

The second command uses the Start-Service cmdlet to start the WMI service. It identifies the service by using the InputObject parameter to pass the $s variable containing the WMI service object to Start-Service. Then, it uses the PassThru parameter to create an object that represents the starting of the service. Without this parameter, Start-Service does not create any output.

The pipeline operator (|) passes the object that Start-Service creates to the Format-List cmdlet, which formats the object as a list of its properties. The append redirection operator (>>) redirects the output to the services.txt file, where it is added to the end of the existing file.


PS C:\> $s = get-service wmi
PS C:\>start-service -InputObject $s -passthru | format-list >> services.txt

-------------------------- EXAMPLE 4 --------------------------

This series of commands shows how to start a service when the start type of the service is "Disabled". The first command, which uses the Start-Service cmdlet to start the Telnet service (tlntsvr), fails.


The second command uses the Get-WmiObject cmdlet to get the Tlntsvr service. This command retrieves an object with the start type property in the StartMode field. The resulting display reveals that the start type of the Tlntsvr service is "Disabled".


The next command uses the Set-Service cmdlet to change the start type of the Tlntsvr service to "Manual".


Now, we can resubmit the Start-Service command. This time, the command succeeds.


To verify that the command succeeded, run Get-Service.


PS C:\>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 C:\>get-wmiobject win32_service | where-object {$_.Name -eq "tlntsvr"}

ExitCode  : 0
Name      : TlntSvr
ProcessId : 0
StartMode : Disabled
State     : Stopped
Status    : OK
PS C:\>set-service tlntsvr -startuptype manual
PS C:\>start-service tlntsvr

Related topics



Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft