Contact Us 1-800-596-4880

Microsoft Windows PowerShell Connector - Mule 4

Microsoft Windows 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.

Before You Begin

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 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 powershell.

  4. Click Dependency Snippets.

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.

View on GitHub