Power shell scripts

Hello everyone,

I am just wondering if workflow can run power shell scripts and code. I have one script, and when I run it manually it works fine but when I call it from workflow process it doesn’t work entirely.
It is supposed to create excel files but instead it does everything else I stated in the script but it doesn’t create files. that part is a power shell code.
Did anyone had same issue or any idea how to solve it?

best regards
Ivan

Calling PowerShell from a process works just fine, either through the External Program task or through the Watch.ExecuteExternalProgram() method in a script.

However, if your Powershell script is creating Excel files via the Excel.Application object, then you will run into issues because that object (and any other MS Office object, for that matter) does not work properly when run from within a service (which explains why it runs correctly in step by step mode).

Phil thank you for your reply.
Please can you check the code below that isn’t working.

powershell.exe -ExecutionPolicy Bypass -Command “try { Import-Csv ‘%%F’ -Delimiter ‘;’ -Encoding Unicode | Export-Excel -Path ‘%directoryPath%\output!excelFile!.xlsx’ -TableStyle Medium2 -ErrorAction Stop } catch { Write-Host ‘Error: $_’ }”

Does something refer to what you said?

Best regards
Ivan

Your code is using the Export-Excel module, which is not native to PowerShell (I am presuming it was installed as an add-on). I briefly glanced at the code for that module but it’s a sizeable piece of code that would require a fair amount of analysis. I would recommend you contact its developer to ask if this module has been tested when running inside a service.

I checked his youtube video presenting the module and one of the first comments under that video reports a problem similar to yours : the module runs fine when run interactively, but errors out when run through Jenkins (another application).

Unfortunately, I don’t think there’s much we can do on our end.

Ok, thank you Phil for your assistance.

Best regards,
Ivan