Customer Portal

Powershell and SysExecute on Designer

Comments 2

  • Avatar
    Vladimir Barton
    0
    Comment actions Permalink

    Hi Pinar,

    First off, I'd suggest using the ExecuteScript component instead of SystemExecute because ExecuteScript, in fact, represents a successor to SystemExecute. It is a well maintained and more advanced component with visual mapping options similar to other common CloverDX components.

    The easiest approach to your challenge would be to prefix your command with "powershell" which is something that normally works in the default Windows shell (cmd) as well. Example script content:

    The next step would be to manipulate the script content in a way to remove the carriage return and line feed white space characters (CRLF) using CTL, thus resolving the misinterpretation of new lines. In regards to the screenshot above, you can use the replace() CTL function in the Map component as follows:

    $out.0.script = replace($in.0.script, "\r\n", "");

    This will replace all CRLF characters with an empty string, thus effectively removing them:

    The last missing piece of the puzzle would be the input mapping in ExecuteScript. You would want to configure it as shown below. All other component properties can stay at defaults.

    This is what we get on the ExecuteScript success port:

    {path/to/my/working/directory}>powershell -command "$a = 10; $b = 20; $sum = $a + $b; Write-Host 'The sum of numbers' $a 'and' $b 'is' $sum;" 
    The sum of numbers 10 and 20 is 30

    Regards,

    -Vladi

  • Avatar
    uykusuzzzz
    0
    Comment actions Permalink

    This is perfect. I will try with this other component. Thank you, Pinar

Please sign in to leave a comment.