Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
jrathgebercs
Creator
Creator

Looking for Command/PowerShell script to update the user id and password of QMC data connection.

Hi All,

We don't have permission to enter manual service user password. 

Do we have any Command/PowerShell script to update the user id and password of QMC data connection.?

jrathgebercs_2-1741197927962.png

 

jrathgebercs_1-1741197643004.png

Could you please help on this to resolve this issue.

Thank you.!!

 

3 Replies
jrathgebercs
Creator
Creator
Author

Hi All,

I am able to update the manual QMC data connection password using below script.

echo off
SET PGPASSWORD=Qlik@123
echo Qlik password %PGPASSWORD%
cd /D "D:\Program Files\Qlik\Sense\Repository\PostgreSQL\14\bin\"
psql -h localhost -p 4432 -U postgres -d QSR
UPDATE public."DataConnections" SET "PasswordString"='%PGPASSWORD%' WHERE "Name"='Mydataconenciton ';

But when I am trying to pass the password variable that is not working. Could you please suggest how can id pass the variable in update command last line in my script.

Thank you.!!!

jrathgebercs
Creator
Creator
Author

Hi All,

I am facing one issue after update data connection using script.

jrathgebercs_0-1741596086311.png

 

Thank you.!!

jrathgebercs
Creator
Creator
Author

Hi All,

Still I am looking solution for this. I got script from Qlik community URL (https://community.qlik.com/t5/Deployment-Management/Update-Password-in-DataConnections-automatically...) and trying to use but getting some error. Could you please suggest me where we need to change in this script.

# Prompt for password
$Password = Read-Host -Prompt 'Input the  new password'
# Store the Base64 Encoded package in the Host.cfg for connection
$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 to Qlik Sense using an internal account (sa_api)
Connect-Qlik -ComputerName https://$($FQDN):4242 -Username INTERNAL\sa_api
# Expose all elements of the JSON response
$rawoutput=$true
# Get the DataConnection JSON for a particular data connection
$RESTapp = Invoke-QlikGet -path "/qrs/dataconnection/full?filter=(name eq 'BMS2014')"
# 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

 I am getting below error while executing above script.:

Connect-Qlik : The term 'Connect-Qlik' is not recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\Users\Myuser\Desktop\qlik_sense_pwd_change.ps1:8 char:1
+ Connect-Qlik -ComputerName https://$($FQDN):4242 -Username INTERNAL\s ...
+ ~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Connect-Qlik:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

Invoke-QlikGet : The term 'Invoke-QlikGet' is not recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\Users\Myuser\Desktop\qlik_sense_pwd_change.ps1:12 char:12
+ $RESTapp = Invoke-QlikGet -path "/qrs/dataconnection/full?filter=(nam ...
+ ~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Invoke-QlikGet:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

Invoke-QlikGet : The term 'Invoke-QlikGet' is not recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\Users\Myuser\Desktop\qlik_sense_pwd_change.ps1:16 char:14
+ $RESTappDC = Invoke-QlikGet -path /qrs/dataconnection/$RESTappID
+ ~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Invoke-QlikGet:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

Invoke-QlikPut : The term 'Invoke-QlikPut' is not recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\Users\Myuser\Desktop\qlik_sense_pwd_change.ps1:22 char:1
+ Invoke-QlikPut -path https://$($FQDN):4242/qrs/dataconnection/$RESTap ...
+ ~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Invoke-QlikPut:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

This is urgent. Please suggest .

 

Thank you.!!