# service::get-status

Gets the status of the specified service.

### Usage

`ServiceControllerStatus service::get-status(service, machineName)`

### Parameters

Name | Type | Description
--- | --- | ---
service | string | The short name that identifies the service to the system.
machineName | string | The computer on which the service resides.

### Return Value

One of the ServiceControllerStatus values that indicates whether the service is running, stopped, or paused, or whether a start, stop, pause, or continue command is pending.

### Remarks

For the machineName parameter, you can use "." or a zero-length String to represent the local computer.

The value returned by service::get-status() can be compared to either a corresponding enum field name or the underlying integral value.

### Examples

- Displays a warning if the Alerter service is stopping on `SV-ARD-EAI1`.

      <if test="${service::get-status('Alerter', 'SV-ARD-EAI1') == 'StopPending'}">
          <echo level="Warning">The Alerter service is stopping.</echo>
      </if>

- The "deploy-web-application" target is only executed if IIS is running on the local computer.

      <target name="deploy" depends="deploy-sql-scripts, deploy-web-application" />

      <target name="deploy-sql-scripts">
          ...
      </target>

      <target name="deploy-web-application" if="$(service::get-status('World Wide Web Publishing', '.') == 4)}">
          ...
      </target>

### Requirements

Assembly: NAnt.Contrib.Tasks (0.85.2479.0)