Powershell script from Mendix?

1
This may be a very basic question. Sorry, if so. I want to call a powershell script within a microflow. Is that possible? Total noob to Mendix...just watched a couple of videos and downloaded the desktop environment. Thanks! 
asked
2 answers
2

If you are running the mendix runtime on-prem on a windows server, you can probably create a custom java action to execute your powershell script from a microflow.

May be better to see if you can use another Activity Directory API (rest, ldap?).

answered
1

Hi there,

you can try to add java action to call poweshell script , like this 

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class PowerShellCommand {

 public static void main(String[] args) throws IOException {

  //String command = "powershell.exe  your command";
  //Getting the version
  String command = "powershell.exe  $PSVersionTable.PSVersion";
  // Executing the command
  Process powerShellProcess = Runtime.getRuntime().exec(command);
  // Getting the results
  powerShellProcess.getOutputStream().close();
  String line;
  System.out.println("Standard Output:");
  BufferedReader stdout = new BufferedReader(new InputStreamReader(
    powerShellProcess.getInputStream()));
  while ((line = stdout.readLine()) != null) {
   System.out.println(line);
  }
  stdout.close();
  System.out.println("Standard Error:");
  BufferedReader stderr = new BufferedReader(new InputStreamReader(
    powerShellProcess.getErrorStream()));
  while ((line = stderr.readLine()) != null) {
   System.out.println(line);
  }
  stderr.close();
  System.out.println("Done");

 }

}
answered