Contact Free trial Login

Microsoft Windows PowerShell Connector - Mule 4

Support Category: Select

Microsoft PowerShell Connector Version 2.0

Anypoint Connector for Microsoft Windows PowerShell (PowerShell Connector) enables you to integrate Windows administration tasks into Mule applications. PowerShell Connector enables you to connect to any machine, local or remote, to execute script files and commands on those machines. You can use SSH to execute PowerShell scripts on a remote Windows or Linux (Ubuntu) machine and have the result processed within Mule runtime engine (Mule).

The connector does not support executing a PowerShell script on a MacOS computer.

For information about compatibility and fixed issues, see Microsoft Powershell Connector Release Notes.

Prerequisites

To use this connector, you must be familiar with:

  • Anypoint Connectors

  • Mule runtime engine (Mule)

  • Elements in a Mule flow

  • Global elements

  • How to create a Mule app using Design Center or Anypoint Studio

To work with PowerShell Connector, you must first install an SSH server on a Windows or Linux (Ubuntu) remote machine:

Add a POM File Dependency

<dependency>
  <groupId>com.mulesoft.connectors</groupId>
  <artifactId>mule-powershell-connector</artifactId>
  <version>x.x.x</version>
  <classifier>mule-plugin</classifier>
</dependency>

Verify that the connector version corresponds to the one you are using.

To obtain the most up-to-date pom.xml file information:

  1. Go to Anypoint Exchange.

  2. In Exchange, click Login and supply your Anypoint Platform username and password.

  3. In Exchange, search for hdfs.

  4. Click Dependency Snippets.

Connect in Anypoint Design Center

  1. Click a trigger.

    You can use an HTTP Listener to receive input from HTTP, or use another component, such as a Scheduler when you want an action to be triggered at a specified time.

  2. Select the connector as a component:

    PowerShell Connector find the connector
  3. Select an operation:

    PowerShell Connector choose operation
  4. Set up a Windows or Linux PowerShell configuration:

    PowerShell Connector choose configuration
    1. Set up PowerShell Linux configuration:

      PowerShell Connector Linux configuration
    2. Set up PowerShell Windows configuration:

      PowerShell Connector Windows configuration
      Fields Description

      Configuration

      PowerShell

      Connection

      Connection Type

      Choose Windows or Linux

      IPAddress

      IP address of the computer to which you want to connect

      User Name

      User name required to authenticate through SSH

      Password

      Password associated with the user name

      To make a simple flow, select these operations:

      • Execute command operation:

        PowerShell Connector Execute Command
  5. PowerShell Execute command operation configuration:

    PowerShell Connector action Execute Command
    Fields Description

    Command

    Command that can execute on the client machine.

Add the Connector in Studio

Add PowerShell Connector to a Mule project to automatically populate the XML code with the connector’s namespace and schema location, as well as add the required dependencies to the project’s pom.xml file.

  1. In Anypoint Studio, from the main menu, select File > New > Mule Project.

  2. Enter a name for your Mule project, and click Finish.

  3. In the Mule Palette view, click (X) Search in Exchange.

  4. In Add Modules to Project, type powershell in the search field.

  5. Click the name of the connector in Available modules.

  6. Click Add.

  7. Click Finish.

Adding a connector to a Mule project in Studio does not make that same connector available to other projects in your Studio workspace.

Configure a Global Element in Studio

  1. In Studio, click the Global Elements tab at the bottom of the canvas.

  2. In the Global Configuration Elements screen, click Create:

    Global Configuration Elements Wizard
  3. In the Choose Global Type wizard, expand Connector Configuration, select either Windows Configuration or Linux Configuration, and click OK.

    This selection enables you to connect remotely to the type of operating system that you choose.

  4. Configure the parameters as follows:

    Parameter Description

    Connection

    Connection type: Windows or Linux

    IP Address

    IP address of the machine on which you want to execute the script file or command

    Username

    User associated with the Windows or Linux machine

    Password

    Password associated with the user name

    In the previous image, the placeholder values refer to a configuration file mule-artifact.properties placed in the src/main/resources folder of your project.
    You can enter your credentials in the global configuration properties, or you can reference a configuration file that contains those values.

    To simplify maintenance and improve project reusability, of your project, use a configuration file. Keeping these values in a separate file is useful if you need to deploy to different environments, such as production, development, and QA, where your access credentials differ.

    See Anypoint Connector Configuration for more information.

  5. Keep the Advanced tab default values.

  6. Click Test Connection.

  7. Click OK.

  8. Your configuration should look like this:

    powershell use case config

Next Step

After you configure the PowerShell Connector, see the Examples topic for more configuration information.