<dependency>
<groupId>com.mulesoft.connectors</groupId>
<artifactId>mule-powershell-connector</artifactId>
<version>x.x.x</version>
<classifier>mule-plugin</classifier>
</dependency>
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:
-
Windows
-
Download OpenSSH for Win32 or Win64.
-
Follow the OpenSSH installation steps.
-
-
Linux (Ubuntu)
-
Follow the SSH installation steps.
-
Follow install PowerShell on Linux from Microsoft.
-
Add a POM File Dependency
Verify that the connector version
corresponds to the one you are using.
To obtain the most up-to-date pom.xml
file information:
-
Go to Anypoint Exchange.
-
In Exchange, click Login and supply your Anypoint Platform username and password.
-
In Exchange, search for
powershell
. -
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.
-
In Anypoint Studio, from the main menu, select File > New > Mule Project.
-
Enter a name for your Mule project, and click Finish.
-
In the Mule Palette view, click (X) Search in Exchange.
-
In Add Modules to Project, type
powershell
in the search field. -
Click the name of the connector in Available modules.
-
Click Add.
-
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
-
In Studio, click the Global Elements tab at the bottom of the canvas.
-
In the Global Configuration Elements screen, click Create:
-
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.
-
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 thesrc/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.
-
Keep the Advanced tab default values.
-
Click Test Connection.
-
Click OK.
-
Your configuration should look like this:
Next Step
After you configure the PowerShell Connector, see the Examples topic for more configuration information.