Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
tobiasweidemann
Partner - Contributor
Partner - Contributor

Change Dataconnection Password through Qlik-Cli

Hello,

due to a company policy, passwords for all accounts have to be changed in a regular interval including service accounts.
I got a script for updating the password for the Qlik Sense services, which also updates the data connections of the monitor apps.

Updating the services works well, but when it comes to changing the data connections, I get a HTTP error 400 "invalid request".

 

The part of the script, which changes the password of the data connections:

Spoiler
#Datenverbindung ermitteln
    $DataconnectionID = Invoke-QlikGet -path "/qrs/dataconnection/full?filter=(name eq '$connection')";
    #ID der Datenverbindung
    $AppID = $DataconnectionID.id;
    #JSON Konstrukt der Datenverbindung 
    $App_JSON = Invoke-QlikGet -path /qrs/dataconnection/$AppID;
    #Dem JSON Konstrukt ein neues Password zuweisen
    $App_JSON | Add-Member Password $Password -Force;

    #JSON konform konvertieren
    $App_JSON = $App_JSON | ConvertTo-Json;

    #Übermitteln
    Invoke-QlikPut -path https://$($QlikSenseServer):4242/qrs/dataconnection/$AppID -body $App_JSON;

 

1 Solution

Accepted Solutions
rzenere_avvale
Partner - Specialist II
Partner - Specialist II

Hi Tobias,

I haven't tried your code yet, but I have a small question.
Since Qlik-CLI provides functions to work with dataconnections, why not using Update-QlikDataConnection? You can find more through powershell's get-help or directly here: https://github.com/ahaydon/Qlik-Cli/blob/master/resources/dataconnection.ps1

Hope this helps,
Riccardo

View solution in original post

3 Replies
rzenere_avvale
Partner - Specialist II
Partner - Specialist II

Hi Tobias,

I haven't tried your code yet, but I have a small question.
Since Qlik-CLI provides functions to work with dataconnections, why not using Update-QlikDataConnection? You can find more through powershell's get-help or directly here: https://github.com/ahaydon/Qlik-Cli/blob/master/resources/dataconnection.ps1

Hope this helps,
Riccardo

tobiasweidemann
Partner - Contributor
Partner - Contributor
Author

It works now, thank you.

Levi_Turner
Employee
Employee

Yep, there was an added function which handles things.

To do it without the function you're likely missing getting the raw output. Otherwise Qlik-CLI does handing of the dates. Example:

 


$Data = Get-Content C:\ProgramData\Qlik\Sense\Host.cfg
# Convert the base64 encoded install name for Sense to UTF data
$FQDN = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($($Data)))
Connect-Qlik -Username INTERNAL\sa_api -TrustAllCerts
$Password = 'foo'
$rawoutput=$true
# Get the ID of the Data Connection
$RESTapp = Invoke-QlikGet -path "/qrs/dataconnection/full?filter=(name eq 'Temp (qtsel_ltu)')"
# Filter out the ID value for later GET
$RESTappID = $RESTapp.id
# GET the DataConnection JSON
$RESTappDC = Invoke-QlikGet -path /qrs/dataconnection/$RESTappID
# Swap the password out in the JSON
$RESTappDC | Add-Member Password $Password -Force
# Convert to actual JSON
$RESTappDC = $RESTappDC | ConvertTo-Json
# PUT in the new password
Invoke-QlikPut -path https://$($FQDN):4242/qrs/dataconnection/$RESTappID -body $RESTappDC