Skip to content

Instantly share code, notes, and snippets.

@hurrifan1
Created March 5, 2021 16:59
Show Gist options
  • Save hurrifan1/0930add30421a1b9854dca2850a8d7d3 to your computer and use it in GitHub Desktop.
Save hurrifan1/0930add30421a1b9854dca2850a8d7d3 to your computer and use it in GitHub Desktop.
A PowerShell script using Qlik Windows CLI that allows you to archive unused Qlik Sense apps
<# Archive unused apps
# - Reference: https://github.com/ahaydon/Qlik-Cli-Windows
#>
# Connect to Qlik environment with Windows auth (current user) rather than a cert
Connect-Qlik -computername "hostname" -UseDefaultCredentials -TrustAllCerts
# Folder location for storing archived apps
$fldr = "C:\Users\folder\to\store\exported\QVFs"
# my dohusers username
$usr = "username"
# ====================================================================================
# ====================================================================================
# Get my Qlik user ID
$me = Get-QlikUser -filter "userId eq '$usr'"
# Get a list of my apps
$my_apps = Get-QlikApp -filter "owner.userId eq '$usr'" -full
$unused_apps = $my_apps | ? {
( $_.published -eq $false ) `
-and `
( ($_.modifiedDate | Get-Date) -lt (Get-Date).AddDays(-90) ) `
-and `
( ($_.lastReloadTime | Get-Date) -lt (Get-Date).AddDays(-90) )
}
# Use this line to check the apps
$unused_apps | select id, name, modifiedDate, lastReloadTime, published
# Save each app to a local folder and then remove from Qlik
foreach ($app in $unused_apps) {
Write-host "Archiving $($app.name)"
$lm = ($app.modifiedDate | Get-Date).ToString("yyyy-MM-dd hhmm")
Export-QlikApp -id "$($app.id)" -filename "$fldr\$($app.name) (last modified $lm).qvf" -SkipData
Remove-QlikApp -id "$($app.id)"
}
# Open the archive folder to review
ii $fldr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment