Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

rafalcqlik
New Contributor II

Execute powershell command in qv script and reload using distribution service

Hi, I created script in qv to download file from Web page using powershell + BITS. Everything is working fine when I reload document manually but when I run it through management control or just wait for scheduled start, it's not working. There is no error or anything but it just won't download file. I'm log file I can see the script and it looks like there is no issue but I don't get any file. I checked allow to execute external program in document properties. What can be wrong here?

My script:

Let vCOMMAND = 'Import-Module BitsTransfer

Start-BitsTransfer -Source http://ec.europa.eu/eurostat/estat-navtree-portlet-prod/BulkDownloadListing?file=table_of_contents.x... -Destination D:\QLIKVIEW\Dane\WEB\EUROSTAT\table_of_contents.xml';

Execute powershell -command $(vCOMMAND);

Thanks in advance

1 Solution

Accepted Solutions
rafalcqlik
New Contributor II

Re: Execute powershell command in qv script and reload using distribution service

Ok, I found the problem. For some reason powershell command:

Import-Module BitsTransfer

Start-BitsTransfer -Source http://ec.europa.eu/eurostat/estat-navtree-portlet-prod/BulkDownloadListing?file=table_of_contents.x... -Destination D:\QLIKVIEW\Dane\WEB\EUROSTAT\table_of_contents.xml

was not working when reloading with distribution service.

But this one works:

Invoke-WebRequest -Uri http://ec.europa.eu/eurostat/estat-navtree-portlet-prod/BulkDownloadListing?file=table_of_contents.x... -OutFile D:\QLIKVIEW\Dane\WEB\EUROSTAT\table_of_contents.xml

Both commands work fine when reloading manually in QlikView desktop.

6 Replies
Lech_Miszkiewicz
Honored Contributor III

Re: Execute powershell command in qv script and reload using distribution service

does the user running your QlikView service has an access to this file/rights to execute command statement. Remember, that running it localy you are running it with your credentials, when triggering from server you are using service account credentials.

pozdr.

Lech

cheers Lech
When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". This will help community members and Qlik Employees know which discussions have already been addressed and have a possible known solution.
Please LIKE threads if the provided solution is helpful to the problem, but does not necessarily solve the indicated problem.
rafalcqlik
New Contributor II

Re: Execute powershell command in qv script and reload using distribution service

Yes, it has access to that file. It's the same user. QlikView Service is running on the same user I'm using to develop documents. It has full admin rights.

Highlighted
Lech_Miszkiewicz
Honored Contributor III

Re: Execute powershell command in qv script and reload using distribution service

check this topic and see whether you are missing something:

https://qlikviewcookbook.com/2016/01/authorizing-the-script-execute-statement/

cheers

Lech

cheers Lech
When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". This will help community members and Qlik Employees know which discussions have already been addressed and have a possible known solution.
Please LIKE threads if the provided solution is helpful to the problem, but does not necessarily solve the indicated problem.
rafalcqlik
New Contributor II

Re: Execute powershell command in qv script and reload using distribution service

I also found this topic and tried that before I created new discussion. Nothing works...

rafalcqlik
New Contributor II

Re: Execute powershell command in qv script and reload using distribution service

Ok, I found the problem. For some reason powershell command:

Import-Module BitsTransfer

Start-BitsTransfer -Source http://ec.europa.eu/eurostat/estat-navtree-portlet-prod/BulkDownloadListing?file=table_of_contents.x... -Destination D:\QLIKVIEW\Dane\WEB\EUROSTAT\table_of_contents.xml

was not working when reloading with distribution service.

But this one works:

Invoke-WebRequest -Uri http://ec.europa.eu/eurostat/estat-navtree-portlet-prod/BulkDownloadListing?file=table_of_contents.x... -OutFile D:\QLIKVIEW\Dane\WEB\EUROSTAT\table_of_contents.xml

Both commands work fine when reloading manually in QlikView desktop.

Lech_Miszkiewicz
Honored Contributor III

Re: Execute powershell command in qv script and reload using distribution service

Good kn you mate!

cheers Lech
When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". This will help community members and Qlik Employees know which discussions have already been addressed and have a possible known solution.
Please LIKE threads if the provided solution is helpful to the problem, but does not necessarily solve the indicated problem.
Community Browser