NAME
Start-Service
SYNOPSIS
Starts one or more stopped services.
SYNTAX
Start-Service [-Name] <string[]> [-Exclude <string[]>] [-Include <string[]>] [-PassThru] [-Confirm] [-WhatIf] [<CommonParameters>]
Start-Service -DisplayName <string[]> [-Exclude <string[]>] [-Include <string[]>] [-PassThru] [-Confirm] [-WhatIf] [<CommonParameters>]
Start-Service [-InputObject <ServiceController[]>] [-Exclude <string[]>] [-Include <string[]>] [-PassThru] [-Confirm] [-WhatIf] [<CommonParameters>]
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.
Required? true
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-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.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-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.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-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.
Required? false
Position? named
Default value
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.
Required? true
Position? 1
Default value
Accept pipeline input? true (ByValue, ByPropertyName)
Accept wildcard characters? false
-PassThru [<SwitchParameter>]
Returns an object representing the service. By default, this cmdlet does not generate any output.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Confirm [<SwitchParameter>]
Prompts you for confirmation before executing the command.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-WhatIf [<SwitchParameter>]
Describes what would happen if you executed the command without actually executing the command.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
“Get-Help about_CommonParameters“.
INPUTS
System.ServiceProcess.ServiceController, System.String
You can pipe objects that represent the services or strings that contain the service names to Start-Service.
OUTPUTS
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.”
————————– EXAMPLE 1 ————————–
C:\PS>Start-Service -Name eventlog
Description
———–
This command starts the EventLog service on the local computer. It uses the Name parameter to identify the service by its service name.
————————– EXAMPLE 2 ————————–
C:\PS>Start-Service -displayname *remote* -WhatIf
Description
———–
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.
————————– EXAMPLE 3 ————————–
C:\PS>$s = Get-Service wmi
C:\PS>Start-Service -InputObject $s -PassThru | Format-List >> services.txt
Description
———–
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.
————————– EXAMPLE 4 ————————–
C:\PS># Start-Service
Description
———–
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.
C:\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
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”.
C:\PS> Get-WmiObject win32_service | Where-Object {$_.Name -eq “tlntsvr”}
ExitCode : 0
Name : TlntSvr
ProcessId : 0
StartMode : Disabled
State : Stopped
Status : OK
The next command uses the Set-Service cmdlet to change the start type of the Tlntsvr service to “Manual”.
C:\PS> Set-Service tlntsvr -startuptype manual
Now, we can resubmit the Start-Service command. This time, the command succeeds.
C:\PS> Start-Service tlntsvr
To verify that the command succeeded, use Get-Service.
RELATED LINKS
Online version: http://go.microsoft.com/fwlink/?LinkID=113406
Get-Service
Suspend-Service
Stop-Service
Restart-Service
Resume-Service
Set-Service
New-Service