Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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?
Hi,
Apologies.
i have udpdated content based on the below article.
let us know if you have solution fo rthis issue.
Regards,
Balaji
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
@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
Great script...
the only think missing is a function to reinstate the license for a specific user. Any pointers?
To reinstate the license based on what?
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