<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Deallocation Of License Using PowerShell Script in Management &amp; Governance</title>
    <link>https://community.qlik.com/t5/Management-Governance/Deallocation-Of-License-Using-PowerShell-Script/m-p/1682220#M15705</link>
    <description>&lt;P&gt;Yes as UDC to Oracle&lt;/P&gt;</description>
    <pubDate>Thu, 05 Mar 2020 18:00:25 GMT</pubDate>
    <dc:creator>Rehan</dc:creator>
    <dc:date>2020-03-05T18:00:25Z</dc:date>
    <item>
      <title>Deallocation Of License Using PowerShell Script</title>
      <link>https://community.qlik.com/t5/Management-Governance/Deallocation-Of-License-Using-PowerShell-Script/m-p/1677713#M15636</link>
      <description>&lt;P&gt;We are currently working with Qlik Sense Nov 2019 Release and we have use like below:&lt;/P&gt;&lt;P&gt;1)We are using Attrib table coming from Oracle to Allocate the licenses.&lt;/P&gt;&lt;P&gt;2)When user logs on the URL if user exists in the Attrib table he is allocated a license&lt;/P&gt;&lt;P&gt;3) tomorrow if the user leaves or no longer needs a license he is removed from the Atrrib table so on the next reload He is not coming in as a User&lt;/P&gt;&lt;P&gt;4) Even though he does not exist in the Attrib table . The license is still Allocated to him cuz Qlik cant Deallocate the license automatically.&lt;/P&gt;&lt;P&gt;How I can write a powershell script t o Deallocate his license.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Feb 2020 18:20:15 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Management-Governance/Deallocation-Of-License-Using-PowerShell-Script/m-p/1677713#M15636</guid>
      <dc:creator>Rehan</dc:creator>
      <dc:date>2020-02-20T18:20:15Z</dc:date>
    </item>
    <item>
      <title>Re: Deallocation Of License Using PowerShell Script</title>
      <link>https://community.qlik.com/t5/Management-Governance/Deallocation-Of-License-Using-PowerShell-Script/m-p/1678574#M15641</link>
      <description>&lt;P&gt;Is that attribute present in Qlik Sense? Are you synchronizing to Oracle as a UDC? If so, what is the format? group = foo? Something else?&lt;/P&gt;</description>
      <pubDate>Mon, 24 Feb 2020 15:12:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Management-Governance/Deallocation-Of-License-Using-PowerShell-Script/m-p/1678574#M15641</guid>
      <dc:creator>Levi_Turner</dc:creator>
      <dc:date>2020-02-24T15:12:05Z</dc:date>
    </item>
    <item>
      <title>Re: Deallocation Of License Using PowerShell Script</title>
      <link>https://community.qlik.com/t5/Management-Governance/Deallocation-Of-License-Using-PowerShell-Script/m-p/1682194#M15704</link>
      <description>&lt;P&gt;Yes we have a attribute called 'Licensetype" with a value of "professional" . I was able to find your script in one o fthe blogs . Please see attached script. How can I use it. Can you please provide the QLik CLI steps to consume the script.&amp;nbsp; We have a subscription model&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#--------------------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;#&lt;BR /&gt;# Script Name: qlik_sense_purge_removed_externally_users.ps1&lt;BR /&gt;# Description: Remove the assigned licenses of users who are marked as removed externally&lt;BR /&gt;# Dependency: Qlik-Cli (&lt;A href="https://github.com/ahaydon/Qlik-Cli" target="_blank"&gt;https://github.com/ahaydon/Qlik-Cli&lt;/A&gt;)&lt;BR /&gt;#&lt;BR /&gt;# Version Date Author Change Notes&lt;BR /&gt;# 0.1 2019-08-23 Levi Turner Initial version&lt;BR /&gt;#--------------------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;P&gt;# Helper function for recording timestamps in the logging&lt;BR /&gt;function Get-TimeStamp {&lt;BR /&gt;return "[{0:MM/dd/yy} {0:HH:mm:ss}]" -f (Get-Date)&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;# More verbose Get-QlikUser function&lt;BR /&gt;function Get-QlikUser {&lt;BR /&gt;[CmdletBinding()]&lt;BR /&gt;param (&lt;BR /&gt;[parameter(Position=0,ValueFromPipelinebyPropertyName=$true)]&lt;BR /&gt;[string]$id,&lt;BR /&gt;[string]$filter,&lt;BR /&gt;[switch]$full,&lt;BR /&gt;[switch]$raw&lt;BR /&gt;)&lt;BR /&gt;&lt;BR /&gt;PROCESS {&lt;BR /&gt;$path = "/qrs/user"&lt;BR /&gt;If( $id ) { $path += "/$id" }&lt;BR /&gt;If( $full ) { $path += "/full" }&lt;BR /&gt;If( $raw ) { $rawOutput = $true }&lt;BR /&gt;$result = Invoke-QlikGet $path $filter&lt;BR /&gt;if( $raw -Or $full ) {&lt;BR /&gt;return $result&lt;BR /&gt;} else {&lt;BR /&gt;$properties = @('name','userDirectory','userId','id','removedExternally')&lt;BR /&gt;#if( $full ) { $properties += @('roles','inactive','blacklisted','removedExternally') }&lt;BR /&gt;return $result | Select-Object -Property $properties&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;# Helper function for removing Analyzer licenses; not found in Qlik-Cli when script was being built&lt;BR /&gt;function Remove-QlikAnalyzerAccessType {&lt;BR /&gt;[CmdletBinding()]&lt;BR /&gt;param (&lt;BR /&gt;[parameter(Position=0,ValueFromPipelinebyPropertyName=$true)]&lt;BR /&gt;[string]$id&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;PROCESS {&lt;BR /&gt;return Invoke-QlikDelete -path "/qrs/license/analyzeraccesstype/$id"&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;function Remove-QlikProfessionalAccessType {&lt;BR /&gt;[CmdletBinding()]&lt;BR /&gt;param (&lt;BR /&gt;[parameter(Position=0,ValueFromPipelinebyPropertyName=$true)]&lt;BR /&gt;[string]$id&lt;BR /&gt;)&lt;BR /&gt;&lt;BR /&gt;PROCESS {&lt;BR /&gt;return Invoke-QlikDelete -path "/qrs/license/professionalaccesstype/$id"&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;# Logging&lt;BR /&gt;Set-Location $PSScriptRoot&lt;BR /&gt;$logdir = $PSScriptRoot + '\logs'&lt;BR /&gt;$logfile = $logdir + "\" + (Get-Date -Format yyyyMMdd) + ".log"&lt;BR /&gt;if (!(Test-Path $logdir)){&lt;BR /&gt;New-Item -path $logdir -type directory | Out-Null&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;# Connect to Qlik Sense&lt;BR /&gt;Connect-Qlik&lt;/P&gt;&lt;P&gt;# Clearing out Variables&lt;BR /&gt;$tokenusers = ''&lt;/P&gt;&lt;P&gt;# Get the version of QRS to figure out license model&lt;BR /&gt;$version = Invoke-QlikGet -path /qrs/about&lt;BR /&gt;Write-Output "$(Get-TimeStamp) : Build version: $($version.buildversion)" | Out-File -FilePath $logfile -Append&lt;/P&gt;&lt;P&gt;# If the version of QRS is less than April, tokens are being used, otherwise will need to check&lt;BR /&gt;if ($($version.buildVersion) -lt '20.4.2.0') {&lt;BR /&gt;Set-Variable -Name "licensemodel" -Value "token"&lt;BR /&gt;} else {&lt;BR /&gt;Set-Variable -Name "licensemodel" -Value "variable"&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;# Get list of users assigned named licenses&lt;BR /&gt;if ($($licensemodel) -eq 'variable') {&lt;BR /&gt;# if 2018-04 or higher then get the overview to later determine which license model is in effect&lt;BR /&gt;$LicenseOverview = Invoke-QlikGet -path /qrs/License/accesstypeoverview&lt;BR /&gt;Write-Output "$(Get-TimeStamp) : $($LicenseOverview)" | Out-File -FilePath $logfile -Append&lt;/P&gt;&lt;P&gt;if ($($LicenseOverview).totalTokens -eq '0') {&lt;BR /&gt;# If the totalTokens value in the LicenseOverview response zero, then get Professional User allocations&lt;BR /&gt;Set-Variable -Name "licensemodel" -Value "pa" -Force&lt;BR /&gt;$professionalusers = Invoke-QlikGet -path '/qrs/License/ProfessionalAccessType/full'&lt;BR /&gt;Write-Output "$(Get-TimeStamp) : $($professionalusers.count) professional licenses" | Out-File -FilePath $logfile -Append&lt;BR /&gt;$analyzerusers = Invoke-QlikGet -path '/qrs/License/AnalyzerAccessType/full'&lt;BR /&gt;Write-Output "$(Get-TimeStamp) : $($analyzerusers.count) analyzer licenses" | Out-File -FilePath $logfile -Append&lt;/P&gt;&lt;P&gt;} else {&lt;/P&gt;&lt;P&gt;# If the totalTokens value in the LicenseOverview response is non-zero then the token model is in use, get user access pass allocations&lt;BR /&gt;Set-Variable -Name "licensemodel" -Value "token" -Force&lt;BR /&gt;$tokenusers = Invoke-QlikGet -path '/qrs/License/UserAccessType/full'&lt;BR /&gt;Write-Output "$(Get-TimeStamp) : $($tokenusers.count) licenses" | Out-File -FilePath $logfile -Append&lt;BR /&gt;}&lt;BR /&gt;} else {&lt;BR /&gt;# if 2018-02 or earlier, then use token model and get user access pass allocations&lt;BR /&gt;Set-Variable -Name "licensemodel" -Value "token" -Force&lt;BR /&gt;$tokenusers = Invoke-QlikGet -path '/qrs/License/UserAccessType/full'&lt;BR /&gt;Write-Output "$(Get-TimeStamp) : $($tokenusers.count) licenses" | Out-File -FilePath $logfile -Append&lt;BR /&gt;}&lt;BR /&gt;# Remove-QlikProfessionalAccessType&lt;BR /&gt;# Remove-QlikUserAccessType&lt;BR /&gt;# Remove-QlikAnalyzerAccessType&lt;/P&gt;&lt;P&gt;# if/else for iterating over the users&lt;BR /&gt;# If the tokenusers variable is null iterate over the p/a users, else token users&lt;BR /&gt;if (!$tokenusers) {&lt;BR /&gt;# P/A Model&lt;BR /&gt;ForEach ($user in $professionalusers) {&lt;BR /&gt;$licenseusers = ''&lt;BR /&gt;$licenseusers = Get-QlikUser -id $user.user.id&lt;BR /&gt;if ($licenseusers.removedExternally -eq 'False') {&lt;BR /&gt;# Users are removedExternally = True&lt;BR /&gt;Write-Output "Removing Professional license for $($user.user.userDirectory)/$($user.user.userId) (User Name: $($user.user.name))" | Out-File -FilePath $logfile -Append&lt;BR /&gt;Remove-QlikProfessionalAccessType -id $user.id&lt;BR /&gt;} else {&lt;BR /&gt;# Users are removedExternally = False&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;ForEach ($analyzeruser in $analyzerusers) {&lt;BR /&gt;$analyzerlicenses = ''&lt;BR /&gt;$analyzerlicenses = Get-QlikUser -id $analyzeruser.user.id&lt;BR /&gt;if ($analyzerlicenses.removedExternally -eq 'False') {&lt;BR /&gt;# Users are removedExternally = True&lt;BR /&gt;Write-Output "Removing Analyzer license for $($analyzeruser.user.userDirectory)\$($analyzeruser.user.userId) (User Name: $($analyzeruser.user.name))" | Out-File -FilePath $logfile -Append&lt;BR /&gt;Remove-QlikAnalyzerAccessType -id $analyzeruser.id&lt;BR /&gt;} else {&lt;BR /&gt;# Users are removedExternally = False&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;} else {&lt;BR /&gt;Write-Host "Token model"&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Mar 2020 16:56:53 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Management-Governance/Deallocation-Of-License-Using-PowerShell-Script/m-p/1682194#M15704</guid>
      <dc:creator>Rehan</dc:creator>
      <dc:date>2020-03-05T16:56:53Z</dc:date>
    </item>
    <item>
      <title>Re: Deallocation Of License Using PowerShell Script</title>
      <link>https://community.qlik.com/t5/Management-Governance/Deallocation-Of-License-Using-PowerShell-Script/m-p/1682220#M15705</link>
      <description>&lt;P&gt;Yes as UDC to Oracle&lt;/P&gt;</description>
      <pubDate>Thu, 05 Mar 2020 18:00:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Management-Governance/Deallocation-Of-License-Using-PowerShell-Script/m-p/1682220#M15705</guid>
      <dc:creator>Rehan</dc:creator>
      <dc:date>2020-03-05T18:00:25Z</dc:date>
    </item>
  </channel>
</rss>

