Ensure Service
  • 14 May 2021
  • 1 Minute to read
  • Dark
    Light
  • PDF

Ensure Service

  • Dark
    Light
  • PDF

Article Summary

This is generated from the built in components of Otter 3.0.0, and may be different than what you have installed (especially if you have extensions); go to [User Icon] -> Documentation within your BuildMaster instance to see exactly what operations are available.

Ensure Service

Ensures the configuration of a Windows service on a server.

Script usage:

Ensure-Service(
	Name: <text>,
	[DisplayName: <text>],
	[Description: <text>],
	[Status: <integer>],
	[Exists: <true/false>],
	Path: <text>,
	[Startup: <integer>],
	[DelayedStart: <true/false>],
	[Credentials: <text>],
	[UserName: <text>],
	[Password: <text>],
	[FirstFailure: <integer>],
	[SecondFailure: <integer>],
	[SubsequentFailures: <integer>],
	[RestartDelay: <integer>],
	[OnFailureProgramPath: <text>],
	[RebootMessage: <text>],
	[Dependencies: <@(text)>],
	[StatusChangeTimeout: <TimeSpan>]
);

This operation may be prefixed with Windows::, although this is a built-in namespace and isn't really necessary.

Arguments:

NameFormatScript UsageUsage Notes
Name
text
Name
This argument is required.
Display name
text
DisplayName
Description
text
Description
Status
integer
Status
Exists
true/false
Exists
Path w/ arguments
text
Path
The executable path of the service. This field may include any arguments that will be supplied to the executable. Executable paths that include spaces should be wrapped with double-quotes, e.g.: "C:\Program Files\Hdars\Hdars.Service.exe" -arg1 -arg2 This argument is required.
Startup
integer
Startup
Startup type
DelayedStart
true/false
DelayedStart
Delayed start
Credentials
text
Credentials
The Otter credential name to use as the service's Log On user. If a credential name is specified, the username and password fields will be ignored.
User name
text
UserName
The user account name to run the service as. If this value is not supplied, NT AUTHORITY\LocalSystem will be assumed.
Password
text
Password
The password for the account that runs the service. If NT AUTHORITY\LocalSystem is specified, this field must not have a value set.
First failure
integer
FirstFailure
Second failure
integer
SecondFailure
Subsequent failures
integer
SubsequentFailures
Restart delay
integer
RestartDelay
Run program
text
OnFailureProgramPath
Reboot message
text
RebootMessage
Dependencies
@(text)
Dependencies
Status change timeout
TimeSpan
StatusChangeTimeout
The number of seconds to wait for a server to change between two statuses (e.g. stopped to starting) before raising an error.

Example:

# ensures the HdarsSvc is present on the server using the HdarsSvc credentials in Otter
Windows::Ensure-Service
(
    Name: HdarsSvc,
    DisplayName: HDARS Console Log Service,
    Status: Running,
    Path: E:\Services\Hdars.Service.exe,
    Startup: Auto,
    Credentials: HdarsSvc,
    FirstFailure: Restart
);

Was this article helpful?