Installs a Windows service.
Install-Service -Name <String> -Path <String> [-StartupType {Automatic | Manual | Disabled}] [-OnFirstFailure <String>] [-OnSecondFailure <String>] [-OnThirdFailure <String>] [-ResetFailureCount <Int32>] [-RestartDelay <Int32>] [-RebootDelay <Int32>] [-Dependency <String[]>] [-WhatIf] [-Confirm] [<CommonParameters>]
Install-Service -Name <String> -Path <String> [-StartupType {Automatic | Manual | Disabled}] [-OnFirstFailure <String>] [-OnSecondFailure <String>] [-OnThirdFailure <String>] [-ResetFailureCount <Int32>] [-RestartDelay <Int32>] [-RebootDelay <Int32>] [-Dependency <String[]>] -Username <String> -Password <String> [-WhatIf] [-Confirm] [<CommonParameters>]
Installs a Windows service. If a service with the given name already exists, it is left in place, and the its configuration is updated to match the parameters passed in. In order to configure it, the service is stopped, configured, then started. By default, the service is installed to run as NetworkService
. Set the Username
and Password
arguments to run as a different account. This user will be granted the logon as a service right.
The minimum required information to install a service is its name and path. By default the servide will run as NetworkService
and will start automatically. Review the parameter list for additional configuraiton options and their defaults. Normally, we would list them here, but there's like 300 of them and we really don't have the time. I'm so mean, I'm not even going to give you examples of all the different options. Feel free to send in your own.
Name | Type | Description | Required? | Pipeline Input | Default Value |
---|---|---|---|---|---|
Name | String | The name of the service. | true | false | |
Path | String | The path to the service. | true | false | |
StartupType | ServiceStartMode | The startup type: automatic, manual, or disabled. Default is automatic. | false | false | |
OnFirstFailure | String | What to do on the service's first failure. Default is to take no action. | false | false | |
OnSecondFailure | String | What to do on the service's second failure. Default is to take no action. | false | false | |
OnThirdFailure | String | What to do on the service' third failure. Default is to take no action. | false | false | |
ResetFailureCount | Int32 | How many seconds after which the failure count is reset to 0. | false | false | |
RestartDelay | Int32 | How many milliseconds to wait before restarting the service. Default is 60,0000, or 1 minute. | false | false | |
RebootDelay | Int32 | How many milliseconds to wait before handling the second failure. Default is 60,000 or 1 minute. | false | false | |
Dependency | String[] | What other services does this service depend on? | false | false | |
Username | String | The user the service should run as. | true | false | |
Password | String | The user's password. | true | false | |
WhatIf | SwitchParameter | false | false | ||
Confirm | SwitchParameter | false | false | ||
CommonParameters | This cmdlet supports common parameters. For more information type Get-Help about_CommonParameters . |
Install-Service -Name DeathStar -Path C:\ALongTimeAgo\InAGalaxyFarFarAway\DeathStar.exe
Installs the Death Star service, which runs the service executable at C:\ALongTimeAgo\InAGalaxyFarFarAway\DeathStar.exe
. The service runs as NetworkService
and will start automatically.
Install-Service -Name DetahStart -Path C:\ALongTimeAgo\InAGalaxyFarFarAway\DeathStar.exe -StartupType Manual
Install the Death Star service to startup manually. You certainly don't want the thing roaming the galaxy, destroying thing willy-nilly, do you?
Install-Service -Name DetahStart -Path C:\ALongTimeAgo\InAGalaxyFarFarAway\DeathStar.exe -Username EMPIRE\wtarkin -Password 5irewh3nready
Installs the Death Star service to run as Grand Moff Tarkin, who is given the log on as a service right.