Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
rohitk1609
Master
Master

Qlik CLI Command is not working in Windows Task Scheduler

Hi Techies,

I got a use case where I need to trigger a Qlik Sense task right after Windows Task Scheduler task completion.

I have installed and configured Qlik CLI module in powershell. I have created one .ps1 file which has two commands:

Get-ChildItem cert:CurrentUser\My | Where-Object { $_.FriendlyName -eq 'QlikClient' } | Connect-Qlik sense-central; Start-QlikTask "Manually triggered reload of Task" -wait | Wait-QlikExecution

Decoding abvove command in ps1 file:  Connecting certificates Get-ChildItem cert:CurrentUser\My | Where-Object { $_.FriendlyName -eq 'QlikClient' }  

Trigger Qlik Sense task : Connect-Qlik sense-central; Start-QlikTask "Manually triggered reload of Task" -wait | Wait-QlikExecution

When I am running this .ps1 file in powershell it is triggering Qlik task successful but I have a use case where I need to run the above powershell command in windows task scheduler.

Above command I found on page https://github.com/ahaydon/Qlik-Cli

In simple I need to run Qlik Cli command by Windows Task Scheduler.  

I tried few stack over flow solution like https://stackoverflow.com/questions/13015245/powershell-script-wont-execute-as-a-windows-scheduled-t...

but it is not working. 0*1 is the message coming out. Running directly .ps1 file works fine.

Can you please help me to run a Qlik CLI command through Windows Task Scheduler ?

 

Thanks,

Rohit

Labels (2)
1 Solution

Accepted Solutions
Levi_Turner
Employee
Employee

I am not 100% sure what your PowerShell is code is doing. But I'd drop as much to a log file as possible. Example:

Set-Location C:\Temp
Get-ChildItem cert:CurrentUser\My | Where-Object { $_.FriendlyName -eq 'QlikClient' } > temp.log
Connect-Qlik usral-ltu2.qliktech.com -Verbose >> .\temp.log
Get-QlikTask  -filter " name eq 'Reload task of Operations Monitor'" >> temp.log
Start-QlikTask "Reload task of Operations Monitor" -wait | Wait-QlikExecution

 

View solution in original post

8 Replies
Levi_Turner
Employee
Employee

rohitk1609
Master
Master
Author

Thanks Levi for your input. I tried your article but still it is not working. I am sharing few snapshots so you can find the flaw:

Untitled.png

 

 

 

 

 

 

 

Untitled.png

 

 

 

 

 

 

 

Untitled.png

 

 

 

 

 

 

 

and result is :

Last run result: (0*1)

If I run the file by right click=> run as powershell so it works absolutely fine.

Please help me to fix it

Thanks,

Rohit

Levi_Turner
Employee
Employee

I am not 100% sure what your PowerShell is code is doing. But I'd drop as much to a log file as possible. Example:

Set-Location C:\Temp
Get-ChildItem cert:CurrentUser\My | Where-Object { $_.FriendlyName -eq 'QlikClient' } > temp.log
Connect-Qlik usral-ltu2.qliktech.com -Verbose >> .\temp.log
Get-QlikTask  -filter " name eq 'Reload task of Operations Monitor'" >> temp.log
Start-QlikTask "Reload task of Operations Monitor" -wait | Wait-QlikExecution

 

siddharth_s3
Partner - Creator II
Partner - Creator II

I generally run a batch file which triggers the powershell.

Works flawlessly that way.

rohitk1609
Master
Master
Author

Thanks Levi. Big fan of yours.

Sangeeta
Contributor II
Contributor II

Hi, I'm getting the same problem when trying to run the task using SYSTEM user (with highest privilege). Please let me know if if possible to run task scheduler with SYSTEM user.

Levi_Turner
Employee
Employee

@Sangeeta : I cannot imagine that it wouldn't work. I am not a Windows Admin to speak on every detail here, but this example works fine for me:

Set-Location C:\tmp
Get-PfxCertificate .\client.pfx | Connect-Qlik -ComputerName us-ea-hybrid-qs -UserName INTERNAL\sa_api -TrustAllCerts
Start-QlikTask "Reload Operations Monitor" -wait | Wait-QlikExecution

 

Levi_Turner_0-1712332500002.png

 

Doing Windows authentication (ref) is not apt to work, although you can try it. I don't see why I'd rely on it, myself. Likewise, concepts like fetching the client certificate from the user's personal cert store (Get-ChildItem cert:CurrentUser\My | Where-Object { $_.FriendlyName -eq 'QlikClient' }) doesn't make much sense. You may be able to store a cert to the SYSTEM account, but I'd refer you to Microsoft documentation on such matters. The only logical auth mechanism seems to me to be to use a certificate stored to disk.

Sangeeta
Contributor II
Contributor II

Connect-Qlik command run fine for me but next command I ran is to update certificate thumbprint in the proxy. I'm using the below command for updating proxy, it runs fine when I run the powershell script manually but won't run with task scheduler.

Update-QlikProxy -id (Get-QlikProxy -full).id -SslBrowserCertificateThumbprint $thumbprint