Action Spotlight: Querying a Database

Create a Custom Action to access and manage databases.

Introduction

RemoteLink allows you to add configurable Actions to a Task Script, providing a low-code method of building intelligent work processes.

Here’s an example of a Task Script that is designed to identify and disable RemoteLink Clients that have not recently connected. For this example, the ‘Run SQL Query with Parameters’ Custom Action is used to query the RemoteLink database for Clients that have not connected in the last three weeks. The ‘For Each’ and ‘Run DCQ’ System Actions are then leveraged to disable each of the Clients returned by the query.

‘Run SQL Query with Parameters’ is a Custom Action that was built by a RemoteLink administrator. Below, we break down how it was created.

Action Definition

Action Objective

Provide the ability to query a SQL database with input parameters such as connection string and authentication method.

General Information

The first step when creating an Action is to define some basic details about it. The ‘Run Scope’, or  location where the Action can run is set to ‘User Defined’, which allows the admin user to specify if it should run on the Client or Server when the Action is added to a Task Script.

Fields

The fields, which are presented when adding the Action into a Task Script, are the input parameters that will be consumed during the execution of the Action. The following fields are defined for this Action:

  • SQL Server Name – address for the SQL Server.
  • Database Name – name of the target database.
  • Additional Connection String Options – any additional connection string parameters needed after the SQL Server, database or authentication options.
  • Use Integrated Security – when enabled, integrated security (i.e. the logged in user context) is used for SQL authentication. In our example, it is the RemoteLink service account.
    • When ‘Use Integrated Security’ is disabled, the following options are displayed:
      • SQL Username – username for SQL login.
      • Use Encrypted Password – when enabled, an encrypted password string, which must be seeded ahead of time on each Server/Client that will run this action, is read and decrypted from the local file system.
      • SQL Password – password for SQL login.
  • SQL Query – the SQL statement that will be executed.
  • Variable – the variable that will contain the results of the query.

Payload

This Action leverages a PowerShell script to perform the function. Below is the first part of the Payload that will be executed when the Action is run. You can see references to the fields that were defined as inputs.

Task Output/Logging

The RemoteLink Session Log captures details about each Task Action that is executed. As you can see in the logs from the example Task Script referenced in the introduction, five ‘stale’ clients were returned by the SQL query and were subsequently disabled.

About Actions

Actions are the building blocks for creating Task Scripts. There are dozens of native ‘System Actions’ that enable such work as sending/getting files, controlling registry keys and values, and managing script variables. In addition, administrators can create their own reusable ‘Custom Actions’  that leverage common languages, such as PowerShell or Bash, and/or command programs or shells. Both System and Custom Actions are distributed, executed and logged the same, providing a consistent and complete experience.

Want a copy of this Action?

If you are running v4.5 R3 and would like a copy of this Custom Action that you can import into your environment, just send us an email at support@unwiredremotelink.com.

Want to learn more about Actions?

We’re always happy to discuss the ways RemoteLink can help you solve your endpoint management challenges.