Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
aslam24196
Contributor III
Contributor III

Unable to Execute Powershell Script from External Program Task

Hello Community,

I have a PowerShell script that uses Qlik CLI to generate the File IDs of QVDs from SaaS and store it onto a text file. This Shell script works when I run it manually on the host server but unable to execute it through Qlik Sense for Windows' External Program Task even though the result says success.
The Following is the Qlik CLI Script which works - 
qlik data-file ls --connectionId 4a6e016f-b3db-4301-a934-4cdce133cdfb --limit 500| ConvertFrom-Json | Format-Table id, name > \\QLK-ANA-PUE-001\QlikSenseAppData\BatchScripts\DA-Load\File-Id.txt
 
The Following is the External Program Task:
Path: powershell.exe
Parameters: -NoProfile -ExecutionPolicy Bypass -Command "& {Start-Process PowerShell -ArgumentList '-NoProfile -ExecutionPolicy Bypass -File ""\\qlk-ana-pue-001\QlikSenseAppData\BatchScripts\DA-Load\Run_Generate.ps1""' -Verb RunAs}"
Please help in debugging this issue. 
 
Thanks,
Aslam

Labels (3)
4 Replies
Levi_Turner
Employee
Employee

This setup is running fine on my end:

  • Path: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
  • Parameters:  -ExecutionPolicy Bypass \\server\path\to\script.ps1

I will note that in your example, do be sure that the qlik-cli is in the Path for whatever server(s) is running the command.

aslam24196
Contributor III
Contributor III
Author

The File is on the server 001, the scheduler hosts are 001 and 002. It looks like the task fails when its triggered through 002, even though 002 also has Qlik-CLI in its Environment Variable Path.

Marc
Employee
Employee

when you call the qlik executable. you need  to make sure that there is a copy that is accessible to all nodes. and fully qualify the path.

e.g. your script is here \\qlk-ana-pue-001\QlikSenseAppData\BatchScripts\DA-Load\Run_Generate.ps1

so try putting Qlik.exe in the share then referencing it in your ps1 like
& \\qlk-ana-pue-001\QlikSenseAppData\BatchScripts\qlik.exe 

 

aslam24196
Contributor III
Contributor III
Author

Hi Everyone,

Thank you for your inputs on this.


I got it to work by using the actual path of the file on the host server instead of the network path. i.e, -NoProfile -ExecutionPolicy Bypass "D:\QlikSenseAppData\BatchScripts\DA-Load\Run_Generate.ps1".

I just have two maintain the same set of files on two different hosts now for both the nodes to run the task with the absolute path.