Powershell not working on scheduled run

Hi,

There is something strange on Easymorph.
I have a project with some data transformation that exports some CSV files and then I have a Powershell command to upload those files to BigQuery. Something like this:

bq load --autodetect --noreplace --source_format=CSV [BigQuery destination] [local files]

So… very easy: import data → transform → export CSV → upload those CSV using Powershell.

The problem is this: It works perfectly if I open the project and click on “reload and run”. But if I schedule it or run it with Easymorph Launcher… it won’t. It stops on the CSV export, but never uploads the data to BigQuery using Powershell.

Any ideas on why this is happening?

Hi Daniel,

It’s hard to say what may cause such behavior. EasyMorph Desktop and Launcher are very similar from a technical standpoint. Both are Windows Desktop applications, have the same set of permissions, use exactly the same calculation engine, and run under the same Windows account (I assume you use them both on the same computer).

Make sure that the CSV file is not open in a text editor, and there is nothing else that may block accessing it.

jmmm, maybe is a security setting in Windows?
I have tried several things:

  1. create a .ps1 file and try to run it. It works on the editor, but not on launcher.
  2. Create a shortcut and try to run it. No luck.
  3. Run launcher as admin. No solution :frowning:

but… the task scheduler from Windows works perfectly. If I schedule the powershell script it will work flawlessly.

So, maybe Windows is not allowing any third party application to run a powershell script. Are you familiar with any related security setting?

I’ll keep investigating to post a solution.

To use bq you don’t need PowerShell. You can run it with the “Run program action”.

Also, bq is Python-based. Python requires several system variables configured. Maybe something is off in this regard. E.g. working directory is not specified or something else.

Is definitely something off with Windows. I tried with CMD to run bq, but I just got some errors.

But I just found a workaround!

1. Create a .ps1 file with the Powershell script.

2. Create a new task in Windows Task Scheduler.

3. Run Powershell with this action:
powershell -executionpolicy bypass -File ‘C:\Users\analitica\Documents\my_script_file.ps1’

4. Run program in EasyMorph:
C:\Windows\System32\schtasks.exe

And add this argument:
/RUN /TN “The name of the task”

With this it works perfectly. Yes… maybe this is not the ideal solution. But it works without a big trouble. Can be useful to someone else.

I’m going to try again following your instructions and run bq with “Run program action”… for science :slight_smile:

Thanks for your help!!

UPDATE: Running bq with the “Run program action” didn’t work either. It has the same problem: works in the editor but not in the launcher. I’m very sure this is about a security setting in this Windows install, I don’t know how to fix that. So, this workaround will be the best (not ideal) solution at the moment.