<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Start reload task via powershell in Integration, Extension &amp; APIs</title>
    <link>https://community.qlik.com/t5/Integration-Extension-APIs/Start-reload-task-via-powershell/m-p/2518284#M22207</link>
    <description>&lt;P&gt;Hello @&lt;STRONG&gt;marksouzacosta&lt;/STRONG&gt;,&lt;/P&gt;&lt;P&gt;First of all, sorry for the late reply.&lt;/P&gt;&lt;P&gt;The error still occurs even though I followed your suggestion.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you give me an example script for the qlik-cli?&lt;/P&gt;&lt;P&gt;I can't seem to get anything to work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Tom&lt;/P&gt;</description>
    <pubDate>Tue, 20 May 2025 06:49:11 GMT</pubDate>
    <dc:creator>TomD</dc:creator>
    <dc:date>2025-05-20T06:49:11Z</dc:date>
    <item>
      <title>Start reload task via powershell</title>
      <link>https://community.qlik.com/t5/Integration-Extension-APIs/Start-reload-task-via-powershell/m-p/2516628#M22171</link>
      <description>&lt;P&gt;Hello everyone&lt;/P&gt;&lt;P&gt;Maybe you could help me before I go completely crazy &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I start the reload of a task via Powershell.&lt;BR /&gt;This also works great.&lt;/P&gt;&lt;P&gt;But I have to wait for it to complete before I can continue.&lt;BR /&gt;And that's where the problem starts.&lt;/P&gt;&lt;P&gt;I get a Forbidden 403 when querying.&lt;BR /&gt;But the execution works.&lt;/P&gt;&lt;P&gt;Many thanks in advance&lt;/P&gt;&lt;P&gt;The call:&lt;/P&gt;&lt;P&gt;PS C:\scripts&amp;gt; .\ReloadZZZ.ps1&lt;BR /&gt;Task 'Manually triggered reload of LN Tools' gefunden mit ID: cec2c459-3cc3-4d3c-9c2f-dfc19d67651f&lt;BR /&gt;Starte Task mit URI: &lt;A href="https://qlik.aquis-systems.com:4242/qrs/task/cec2c459-3cc3-4d3c-9c2f-dfc19d67651f/start/synchronous?xrfkey=JLUlSma1w2BEZvYz" target="_blank" rel="noopener"&gt;https://qlik.com:4242/qrs/task/cec2c459-3cc3-4d3c-9c2f-dfc19d67651f/start/synchronous?xrfkey=JLUlSma1w2BEZvYz&lt;/A&gt;&lt;BR /&gt;Task erfolgreich gestartet. Response: @{value=542fe52e-eb56-4657-abca-b77d4d125a33}&lt;BR /&gt;ÃœberprÃ¼fe den Status des Tasks...&lt;BR /&gt;C:\scripts\ReloadZZZ.ps1 : Fehler beim Starten des Tasks oder Abrufen des Status: The remote server returned an error:&lt;BR /&gt;(403) Forbidden.&lt;BR /&gt;At line:1 char:1&lt;BR /&gt;+ .\ReloadZZZ.ps1&lt;BR /&gt;+ ~~~~~~~~~~~~~~~&lt;BR /&gt;+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException&lt;BR /&gt;+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,ReloadZZZ.ps1&lt;BR /&gt;&lt;BR /&gt;The Script:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;# TrustAllCertsPolicy Definition – Verhindert Zertifikatwarnungen&lt;BR /&gt;if (-not ("TrustAllCertsPolicy" -as [type])) {&lt;BR /&gt;Add-Type @"&lt;BR /&gt;using System.Net;&lt;BR /&gt;using System.Security.Cryptography.X509Certificates;&lt;BR /&gt;using System.Net.Security;&lt;/P&gt;&lt;P&gt;public static class TrustAllCertsPolicy {&lt;BR /&gt;public static void Ignore() {&lt;BR /&gt;ServicePointManager.ServerCertificateValidationCallback =&lt;BR /&gt;delegate (object sender, X509Certificate cert, X509Chain chain, SslPolicyErrors sslPolicyErrors) {&lt;BR /&gt;return true;&lt;BR /&gt;};&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;"@&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;[TrustAllCertsPolicy]::Ignore()&lt;BR /&gt;[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12&lt;/P&gt;&lt;P&gt;# === Konfiguration ===&lt;BR /&gt;$qlikServer = "&lt;A href="https://qlik.server.com:4242" target="_blank" rel="noopener"&gt;https://qlik.server.com:4242&lt;/A&gt;"&lt;BR /&gt;$taskName = "Manually triggered reload of LN Tools" # Task Name, der gestartet werden soll&lt;BR /&gt;$certPath = "C:\QlikCerts\s-reb46\client.pfx" # Zertifikatspfad&lt;BR /&gt;$certPassword = "password" # Zertifikatspasswort&lt;/P&gt;&lt;P&gt;# XRF-Key generieren&lt;BR /&gt;$xrfkey = -join ((65..90) + (97..122) + (48..57) | Get-Random -Count 16 | ForEach-Object {[char]$_})&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;# Header vorbereiten&lt;BR /&gt;$headers = @{&lt;BR /&gt;"X-Qlik-User" = "UserDirectory=INTERNAL;UserId=sa_api" # Benutzername für API-Authentifizierung&lt;BR /&gt;"x-qlik-xrfkey" = $xrfkey&lt;BR /&gt;"Content-Type" = "application/json"&lt;BR /&gt;"Accept" = "application/json"&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;# Zertifikat laden&lt;BR /&gt;$cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2&lt;BR /&gt;$cert.Import($certPath, $certPassword, "Exportable,PersistKeySet")&lt;/P&gt;&lt;P&gt;# URL zum Abrufen aller Tasks&lt;BR /&gt;$tasksUri = "$qlikServer/qrs/task?xrfkey=$xrfkey"&lt;BR /&gt;$taskId = $null&lt;/P&gt;&lt;P&gt;# Suche nach dem Task mit dem angegebenen Namen&lt;BR /&gt;try {&lt;BR /&gt;$tasks = Invoke-RestMethod -Uri $tasksUri -Method GET -Headers $headers -Certificate $cert -UseBasicParsing&lt;BR /&gt;foreach ($task in $tasks) {&lt;BR /&gt;if ($task.name -eq $taskName) {&lt;BR /&gt;$taskId = $task.id&lt;BR /&gt;Write-Host "Task '$taskName' gefunden mit ID: $taskId"&lt;BR /&gt;break&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;if (-not $taskId) {&lt;BR /&gt;Write-Host "Kein Task mit dem Namen '$taskName' gefunden!"&lt;BR /&gt;return&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;# URL zum Starten des Tasks&lt;BR /&gt;$startUri = "$qlikServer/qrs/task/$taskId/start/synchronous?xrfkey=$xrfkey"&lt;BR /&gt;Write-Host "Starte Task mit URI: $startUri"&lt;/P&gt;&lt;P&gt;# Task starten&lt;BR /&gt;$response = Invoke-RestMethod -Uri $startUri -Method POST -Headers $headers -Certificate $cert -UseBasicParsing&lt;BR /&gt;Write-Host "Task erfolgreich gestartet. Response: $response"&lt;/P&gt;&lt;P&gt;# Überprüfen, ob der Task erfolgreich abgeschlossen wurde&lt;BR /&gt;$statusUri = "$qlikServer/qrs/reloadtask/$taskId?xrfkey=$xrfkey"&lt;BR /&gt;$taskStatus = ""&lt;/P&gt;&lt;P&gt;# Schleife zur Überprüfung des Status&lt;BR /&gt;do {&lt;BR /&gt;Start-Sleep -Seconds 5 # Alle 5 Sekunden den Status abfragen&lt;BR /&gt;Write-Host "Überprüfe den Status des Tasks..."&lt;/P&gt;&lt;P&gt;$taskStatus = Invoke-RestMethod -Uri $statusUri -Method GET -Headers $headers -Certificate $cert -UseBasicParsing&lt;BR /&gt;$status = $taskStatus.operational.lastExecutionResult.status&lt;BR /&gt;Write-Host "Aktueller Task-Status: $status"&lt;BR /&gt;} while ($status -eq "1" -or $status -eq "2") # Task wartet oder ist noch in Bearbeitung&lt;/P&gt;&lt;P&gt;# Status auswerten und Rückmeldung geben&lt;BR /&gt;switch ($status) {&lt;BR /&gt;3 { Write-Host "Task wurde erfolgreich abgeschlossen." } # Task erfolgreich&lt;BR /&gt;4 { Write-Warning "Task ist fehlgeschlagen." } # Task fehlgeschlagen&lt;BR /&gt;6 { Write-Host "Task wurde abgebrochen." } # Task abgebrochen&lt;BR /&gt;default { Write-Host "Unbekannter Task-Status: $status" } # Unbekannter Status&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;} # Hier fehlte die schließende geschweifte Klammer für den try-Block&lt;BR /&gt;catch {&lt;BR /&gt;Write-Error "Fehler beim Starten des Tasks oder Abrufen des Status: $_"&lt;BR /&gt;}&lt;/P&gt;</description>
      <pubDate>Mon, 05 May 2025 12:37:21 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Integration-Extension-APIs/Start-reload-task-via-powershell/m-p/2516628#M22171</guid>
      <dc:creator>TomD</dc:creator>
      <dc:date>2025-05-05T12:37:21Z</dc:date>
    </item>
    <item>
      <title>Re: Start reload task via powershell</title>
      <link>https://community.qlik.com/t5/Integration-Extension-APIs/Start-reload-task-via-powershell/m-p/2516680#M22173</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/177991"&gt;@TomD&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;I believe you are missing a permission for your sa_api user.&lt;BR /&gt;Try something like this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="marksouzacosta_1-1746450153767.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/180213i2B3E8905356F8E65/image-size/medium?v=v2&amp;amp;px=400" role="button" title="marksouzacosta_1-1746450153767.png" alt="marksouzacosta_1-1746450153767.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In any case, I think you should give a try to Qlik CLI. It is easy to integrate with PowerShell and to execute all the commands you need:&amp;nbsp;&lt;A href="https://qlik.dev/toolkits/qlik-cli/" target="_blank"&gt;https://qlik.dev/toolkits/qlik-cli/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Mark Costa&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 05 May 2025 13:02:54 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Integration-Extension-APIs/Start-reload-task-via-powershell/m-p/2516680#M22173</guid>
      <dc:creator>marksouzacosta</dc:creator>
      <dc:date>2025-05-05T13:02:54Z</dc:date>
    </item>
    <item>
      <title>Re: Start reload task via powershell</title>
      <link>https://community.qlik.com/t5/Integration-Extension-APIs/Start-reload-task-via-powershell/m-p/2518284#M22207</link>
      <description>&lt;P&gt;Hello @&lt;STRONG&gt;marksouzacosta&lt;/STRONG&gt;,&lt;/P&gt;&lt;P&gt;First of all, sorry for the late reply.&lt;/P&gt;&lt;P&gt;The error still occurs even though I followed your suggestion.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you give me an example script for the qlik-cli?&lt;/P&gt;&lt;P&gt;I can't seem to get anything to work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Tom&lt;/P&gt;</description>
      <pubDate>Tue, 20 May 2025 06:49:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Integration-Extension-APIs/Start-reload-task-via-powershell/m-p/2518284#M22207</guid>
      <dc:creator>TomD</dc:creator>
      <dc:date>2025-05-20T06:49:11Z</dc:date>
    </item>
  </channel>
</rss>

