Skip to main content

Deployment & Management

Discussion board where members learn more about Qlik Sense Installation, Deployment and Management.

Announcements
CUSTOMERS ONLY: Now accepting customer applications for the 2023 Luminary Program: SUBMIT NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
william_fu
Creator II
Creator II

Automatic License Deallocation based on inactivity?

Looking for a way to automatically deallocate users' licenses after a certain number of days (based on "last used" column in QMC).

Does anyone know if this is possible?

15 Replies
balaji_MAC
Contributor III
Contributor III

Hi,

Apologies.

i have udpdated content based on the below article.

https://github.com/levi-turner/QlikSenseScripts/blob/master/qlik_sense_purge_unused_user_access_pass...

let us know if you have solution fo rthis issue.

Regards,

Balaji

balaji_MAC
Contributor III
Contributor III

Hi Levi,

Hope you are doing well.

can we get any documents referrance to implement this solution.

we were able to run this script successfully but we didn't any token deallocation.

Note:we are using professional/analyzer license model.

thanks in advance.

Regards,

Balaji

Levi_Turner
Employee
Employee


@balaji_MAC wrote:

...
we were able to run this script successfully but we didn't any token deallocation.

Note:we are using professional/analyzer license model.
...



Because the script was written for the token model.

This guy is a master script which should work no matter the license type:

#--------------------------------------------------------------------------------------------------------------------------------
#
# Script Name: qlik_sense_purge_unused_user_access_passes.ps1
# Description: Remove the assigned user access passes of users who have not used the system in X days
# Dependency: Qlik-Cli (https://github.com/ahaydon/Qlik-Cli)
#           
#   Version     Date        Author          Change Notes
#   0.1         2018-01-30  Levi Turner     Initial Version
#   0.2         2018-03-06  Levi Turner     createdDate > lastUsed
#
#--------------------------------------------------------------------------------------------------------------------------------

$InactivityThreshold = Read-Host -Prompt 'Input the username date threshold for inactivity (e.g. 90)'

# Get date format for 90 days ago
$date = Get-Date
$date = $date.AddDays(-$InactivityThreshold)
$date = $date.ToString("yyyy/MM/dd")
$time = Get-Date
$time = $time.GetDateTimeFormats()[109]
$inactive = $date + ' ' + $time

# Connect to Qlik Sense
$myFQDN=(Get-WmiObject win32_computersystem).DNSHostName+"."+(Get-WmiObject win32_computersystem).Domain
$myFQDN = $myFQDN.ToLower()

# Connect to Qlik-CLI
Connect-Qlik -ComputerName $($myFQDN) 

function Remove-QlikUserAccessType {
  [CmdletBinding()]
  param (
    [parameter(Position=0,ValueFromPipelinebyPropertyName=$true)]
    [string]$id
  )

  PROCESS {
    return Invoke-QlikDelete -path "/qrs/license/useraccesstype/$id"
  }
}

function Get-QlikProfessionalAccessType {
  [CmdletBinding()]
  param (
    [parameter(Position=0)]
    [string]$id,
    [string]$filter,
    [switch]$full,
    [switch]$raw
  )

  PROCESS {
    $path = "/qrs/license/professionalaccesstype"
    If( $id ) { $path += "/$id" }
    If( $full ) { $path += "/full" }
    If( $raw ) { $rawOutput = $true }
    return Invoke-QlikGet $path $filter
  }
}
function Remove-QlikProfessionalAccessType {
  [CmdletBinding()]
  param (
    [parameter(Position=0,ValueFromPipelinebyPropertyName=$true)]
    [string]$id
  )

  PROCESS {
    return Invoke-QlikDelete -path "/qrs/license/professionalaccesstype/$id"
  }
}
function Get-QlikAnalyzerAccessType {
  [CmdletBinding()]
 param (
    [parameter(Position=0)]
    [string]$id,
    [string]$filter,
    [switch]$full,
    [switch]$raw
  )

  PROCESS {
    $path = "/qrs/license/analyzeraccesstype"
    If( $id ) { $path += "/$id" }
    If( $full ) { $path += "/full" }
    If( $raw ) { $rawOutput = $true }
    return Invoke-QlikGet $path $filter
  }
}
function Remove-QlikAnalyzerAccessType {
  [CmdletBinding()]
  param (
    [parameter(Position=0,ValueFromPipelinebyPropertyName=$true)]
    [string]$id
  )

  PROCESS {
    return Invoke-QlikDelete -path "/qrs/license/analyzeraccesstype/$id"
  }
}

Get-QlikUserAccessType -filter "lastUsed lt '$inactive'" -full  | Remove-QlikUserAccessType
Get-QlikAnalyzerAccessType -filter "lastUsed lt '$inactive'" -full  | Remove-QlikAnalyzerAccessType
Get-QlikProfessionalAccessType -filter "lastUsed lt '$inactive'" -full  | Remove-QlikProfessionalAccessType

 

 

itibook
Contributor III
Contributor III

 

Great script... 

the only think missing is a function to reinstate the license for a specific user. Any pointers?

Levi_Turner
Employee
Employee

To reinstate the license based on what?

itibook
Contributor III
Contributor III

 

Sorry if I wasn't clear... 

When I run the script and I call the users concerned become Quarantined in terms of license. 

I was wondering how I could reinstate (that's the term in the QMC) a single user access via the Qlik-Cli or a custom PS script.

I guess it's probably a PUT operation like this one: 

https://help.qlik.com/en-US/sense-developer/June2019/APIs/repositoryserviceapi/index.html?page=30

if something is already out there I'd rather avoid re-inventing the wheel... 🙂

ciao

Luca