Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
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
This approach works perfectly fine for me: https://github.com/levi-turner/1400da7e-fbda-4a02-aa84-a63209c2aa02#config-steps-for-script
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:
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
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
I generally run a batch file which triggers the powershell.
Works flawlessly that way.
Thanks Levi. Big fan of yours.
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.
@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
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.
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