Qlik Community

Qlik Sense Deployment & Management

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

Announcements
See why Qlik is recognized as a Leader for the 10th year in a row – and discover how Qlik can help put your business in the lead. Get Report
Highlighted
william_fu
Contributor 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?

1 Solution

Accepted Solutions
Highlighted
Employee
Employee

Re: Automatic License Deallocation based on inactivity?

Hey William,

Please see this script for a reference: https://github.com/levi-turner/QlikSenseScripts/blob/master/qlik_sense_purge_unused_user_access_pass...

It can be adapted to the subscription licensing if needed and does depend on Qlik-CLI. But it can be used as a reference in either case.

Hope that helps.

View solution in original post

15 Replies
Highlighted
Partner
Partner

Re: Automatic License Deallocation based on inactivity?

Hi William,

I think only if you create a rule where: user.isAnonymous () The token is allocated for 28 days.

But it would not be for inactivity.

I don't think there's any way you can do what you want.

Highlighted
balabhaskarqlik
Honored Contributor

Re: Automatic License Deallocation based on inactivity?

You can, but try this by API like below:

Get a list of license allocation IDs:

GET /qrs/license/useraccesstype/full

Delete a specific license:

DELETE /qrs/license/useraccesstype/{IDfromAbove}

Highlighted
balabhaskarqlik
Honored Contributor

Re: Automatic License Deallocation based on inactivity?

Highlighted
balabhaskarqlik
Honored Contributor

Re: Automatic License Deallocation based on inactivity?

If you want to remove a cal from a user, you can use the QMS API in QlikView to deallocate the cal.  Keep in mind that deallocating the cal does not make it automatically available again.  There is a 24 hour quarantine with QlikView 11.2 and a 7 day quarantine with QlikView 12 before the cal is allowed to be reallocated.

Definitely, do not attempt to modify pgo files.

To my knowledge there is no sample code for performing this activity.  Here is the link to the QMS API: QlikView Management API - Getting Started and Examples

Highlighted
Employee
Employee

Re: Automatic License Deallocation based on inactivity?

Hey William,

Please see this script for a reference: https://github.com/levi-turner/QlikSenseScripts/blob/master/qlik_sense_purge_unused_user_access_pass...

It can be adapted to the subscription licensing if needed and does depend on Qlik-CLI. But it can be used as a reference in either case.

Hope that helps.

View solution in original post

Highlighted
william_fu
Contributor II

Re: Automatic License Deallocation based on inactivity?

Thanks guys,

Can't implement this solution just yet, but this seems to be the way to go.

Partner
Partner

Re: Automatic License Deallocation based on inactivity?

Hello,

I'm trying to use the script, but it seems like nothing is happening after the script is done except for the confirmation of the connection to Qlik Sense.

Anything that I should check? 

Highlighted
balaji_MAC
New Contributor III

Re: Automatic License Deallocation based on inactivity?

Hi Levi,

we tried to implement token auto deallocation using powershell script and we got below error.

Error:

Invoke-RestMethod : The remote name could not be resolved: 'myserver.com'

 

Token unusaed deallocation script:

$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"
}
}

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

Error:

Invoke-RestMethod : The remote name could not be resolved: 'myserver.com'
At C:\Program Files\WindowsPowerShell\Modules\Qlik-Cli\1.15.1\functions\core.ps1:30 char:17
+ ... $result = Invoke-RestMethod -Method $method -Uri $path @params -Ses ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

Do you have any idea how to resolve this error?

Please let us know your input on this.

Regards,

Balaji

Highlighted
Employee
Employee

Re: Automatic License Deallocation based on inactivity?

please note that this could be a violation of the license agreement.