Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
A Customer of ours wants to archive their Qlik Scripts they are using via Powershell.
He found some documentation which says it should be possible via the following endpoint.
https://<qlik-server>/qrs/app/<app-id>/script?xrfkey=<xrf-key>
But when I run a script in powershell for this endpoint I'm receiving a 404 error.
Listing apps, Tasks etc. is working, but the script part gave me a error so i'm in doubt if this is a valid endpoint
Does anyone ever made a solution like this?
You have a long road @DaanBrand1988.
QRS does not return the Load Scripts. You have to use other APIs like @David_Friend suggested and pointed to you.
You could try using Qlik .NET SDK with PowerShell - or even create a .NET app.
This place is a good start:
https://community.qlik.com/t5/Official-Support-Articles/Qlik-Sense-Getting-started-with-the-NET-SDK/...
Another option is to use WebSocket. There is a sample in Python that you can use as reference to create your PowerShell script:
https://community.qlik.com/t5/Official-Support-Articles/Qlik-Sense-call-Qlik-Sense-Engine-API-with-P...
What I would suggest to you is to create a .NET Command Line Application where you can add features and functionalities overtime and use them as you want. You could use the Qlik .NET SDK with a combination of Qlik Rest SDK https://github.com/kolsrud/qlik_rest_sdk to access QRS. This will give you enough power to control almost anything in your Qlik Sense.
Regards,
Mark Costa
Read more at Data Voyagers - datavoyagers.net
Follow me on my LinkedIn | Know IPC Global at ipc-global.com
You have a long road @DaanBrand1988.
QRS does not return the Load Scripts. You have to use other APIs like @David_Friend suggested and pointed to you.
You could try using Qlik .NET SDK with PowerShell - or even create a .NET app.
This place is a good start:
https://community.qlik.com/t5/Official-Support-Articles/Qlik-Sense-Getting-started-with-the-NET-SDK/...
Another option is to use WebSocket. There is a sample in Python that you can use as reference to create your PowerShell script:
https://community.qlik.com/t5/Official-Support-Articles/Qlik-Sense-call-Qlik-Sense-Engine-API-with-P...
What I would suggest to you is to create a .NET Command Line Application where you can add features and functionalities overtime and use them as you want. You could use the Qlik .NET SDK with a combination of Qlik Rest SDK https://github.com/kolsrud/qlik_rest_sdk to access QRS. This will give you enough power to control almost anything in your Qlik Sense.
Regards,
Mark Costa
Read more at Data Voyagers - datavoyagers.net
Follow me on my LinkedIn | Know IPC Global at ipc-global.com
It's exactly what @marksouzacosta and @David_Friend have mentioned above.
The QVS script is stored inside the binary file and therefore can't be access unless you use Engine API's to open the App. Should be enough to open the App without data to access the script.
Only metadata necessary for access control of the App is stored inside QRS today.
all you need to do is tweak the end of the script.
to something like this
#Once we have the App we can Get the Load Script
$AppScript = $QEApp.GetScript()
$AppScript |out-file "C:\Path\to\store\$($AppID).qvs"
$QEApp.Dispose()
First you need to download and Extract the QlikSense.NetSDK from the following
https://www.nuget.org/packages/QlikSense.NetSDK
as well as a copy of Newtonsoft.json.
https://www.nuget.org/packages/Newtonsoft.Json/13.0.3
the nupkg files a just zips, so export them to a path similar to below.
and you will need access to a QlikClient certificate, to ensure you have access to export the scripts.
param(
[bool]$allApps = $false,
[System.IO.DirectoryInfo]$OutputDir = 'C:\temp\AppScripts'
)
$OutputDir.Create()
# Add the Qlik Sense SDK Components
Push-Location $PSScriptRoot
Add-Type -Path '.\Newtonsoft\Newtonsoft.Json.dll'
Add-Type -Path '.\QlikSenseSDK\16.9.0\net462\Qlik.Engine.dll'
Add-Type -Path '.\QlikSenseSDK\16.9.0\net462\Qlik.Engine.Extensions.dll'
Add-Type -Path '.\QlikSenseSDK\16.9.0\net462\Qlik.Sense.JsonRpc.dll'
Add-Type -Path '.\QlikSenseSDK\16.9.0\net462\Qlik.Sense.Client.dll'
Pop-Location
Function Get-ServicePath($Name) {
# Find the repository service
$WinService = Get-WmiObject win32_service | Where-Object { $_.Name -eq $Name } | Select-Object Name, DisplayName, State, PathName
[regex]$EXEPath = '(\\\\|\w:)(.+)(\..{3})'
if ($WinService.PathName -match $EXEPath) { [System.IO.FileInfo]$WinServicePath = $Matches[0] }
$WinService | Add-Member -MemberType NoteProperty -Name Path -Value $WinServicePath
$WinService
}
# Dynamically locate the Install Directory of the Qlik Sense Repository Service
$RepositoryService = Get-ServicePath -Name 'QlikSenseRepositoryService'
[System.IO.DirectoryInfo]$InstallDIR = $RepositoryService.Path.Directory.Parent.FullName
# Import the QlikSenseCLI Module
Import-Module "$($InstallDIR.FullName)\Tools\QlikSenseCLI"
# Find a QlikClient Certificate
$QlikClientCertificate = Get-ChildItem Cert:\CurrentUser\My\ | Where-Object {
$_.Subject -eq 'CN=QlikClient'
}
$UserDirectory = 'Internal'
$UserID = 'sa_api'
$TrustAllCertificates = $true
$paramConnectQlikSense = @{
TrustAllCertificates = $TrustAllCertificates
Certificate = $QlikClientCertificate
Username = "$($UserDirectory)\$($UserID)"
Passthru = $true
}
# Connect to Qlik Sense QRS
$QRSClient = Connect-QlikSense @paramConnectQlikSense
if ($allApps -eq $true) {
$QSApps = Get-QSApp -QlikClient $QRSClient
}
else {
$QSApps = $(Get-QSApp -QlikClient $QRSClient) | Out-GridView -Title 'Select the App to Export QVS' -OutputMode Multiple
}
$Location = [Qlik.Engine.Location]::FromUri($QRSClient.URLQES)
$Location.AsDirectConnection($UserDirectory, $UserID, $QlikClientCertificate, $TrustAllCertificates)
$NoData = $True
for ($AppsI = 0; $AppsI -lt $QSApps.Count; $AppsI++) {
$QSApp = $QSApps[$AppsI]
$QSAppID = $QSApp.ID
$QSAppName = $QSApp.Name
Write-Progress -Activity "Exporting App Scripts" -Status "Exporting $($QSAppID): $($QSAppName)" -PercentComplete (($AppsI / $QSApps.Count) * 100)
#Get the QEApp
$QEApp = [Qlik.Engine.LocationExtensions]::App($Location, $QSAppID, [Qlik.Engine.Session]::Random, $NoData)
$QEApp.GetScript() | Set-Content -Path "$($OutputDir.FullName)\$($QSAppID).qvs"
$QEApp.Dispose()
}
Write-Progress -Activity "Exporting App Scripts" -Status "Finished" -Completed