Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
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?

1 Solution

Accepted Solutions
Levi_Turner
Employee
Employee

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
PabloTrevisan
Partner - Creator II
Partner - Creator II

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.

balabhaskarqlik

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}

balabhaskarqlik

balabhaskarqlik

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

Levi_Turner
Employee
Employee

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.

william_fu
Creator II
Creator II
Author

Thanks guys,

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

adam_groenbeck
Partner Ambassador
Partner Ambassador

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? 

balaji_MAC
Contributor III
Contributor III

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

lhr
Employee
Employee

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