Skip to content

Instantly share code, notes, and snippets.

@hurrifan1
Created April 11, 2022 19:21
Show Gist options
  • Save hurrifan1/29cef215eb71b20f228de4ada9517a01 to your computer and use it in GitHub Desktop.
Save hurrifan1/29cef215eb71b20f228de4ada9517a01 to your computer and use it in GitHub Desktop.
<#
# Migrate data connections
# ========================
#
# Requirements:
# - Qlik CLI tool (🔗 - https://github.com/qlik-oss/qlik-cli)
# - The ID of the data connection to migrate
#
# Steps:
# 1. Login to origin Qlik env.
# 2. Get the full list of Qlik users.
# 3. Clean the data connection for the new Qlik environment.
# 4. Save the settings to temporary JSON file.
# 5. Login to new Qlik env.
# 6. Migrate the data connection by creating it in the new
# env from the temporary JSON file.
# 7. Remove the temporary JSON file.
# 8. Confirm that the new data connection was successfully created.
#>
# ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !
# PLACE DATA CONNECTION ID IN BETWEEN THE QUOTES:
$id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
# ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !
# 1. Login to origin Qlik env
qlik context create QSServer --server https://qlikSense.whatever.gov/ --comment "Qlik Sense server"
qlik context use QSServer
qlik context login
qlik context get
# 2. Get the full list of Qlik users
$og = qlik qrs dataconnection full --filter "id eq $id" --server-type windows
| ConvertFrom-Json -AsHashtable
# 3. Clean the data connection for the new Qlik environment
$og.Remove("id")
$og.Remove("engineObjectId")
$og.Remove("modifiedByUserName")
$og.Remove("username")
$og.Remove("owner")
$og.Remove("modifiedDate")
$og.Remove("createdDate")
$og.Remove("tags")
$og.Remove("customProperties")
# 4. Save the settings to temporary JSON file
$og | ConvertTo-Json > temp_dc.json
# 5. Login to new Qlik env
qlik context create QAPServer --server https://QAP.whatever.gov/ --comment "QAP server"
qlik context use QAPServer
qlik context login
qlik context get
# 6. Migrate the data connection by creating it in the new
# env from the temporary JSON file
qlik qrs dataconnection create --file "temp_dc.json" --server-type windows
# 7. Remove the temporary JSON file
Remove-Item "temp_dc.json"
# 8. Confirm that the new data connection was successfully created
qlik qrs dataconnection full --filter "name eq '$($og.name)'" --server-type windows
| ConvertFrom-Json
| select -Property name, type, createdDate
| Format-List
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment