Qlik Community

Integration, Extension & APIs

Discussion board where members can learn more about Integration, Extensions and API’s for Qlik Sense.

Announcements
IMPORTANT security patches for GeoAnalytics Server available to download: READ DETAILS
cancel
Showing results for 
Search instead for 
Did you mean: 
pavanpatha
Contributor III
Contributor III

Delete admin role

Hi,

 

I would like to delete all admin roles of a user using the QLIK CLI command instead of doing on QMC. i tried below but isnt working. its retaining the old roles. I am able to update the roles though, but unable to remove all of them.

Connect-Qlik

$user=Get-QlikUser -filter "userid eq 'abc'" -full
$str=@()
Update-QlikUser -id $user.id -roles $str

 

Thanks,

Pavan

1 Reply
Damien_Villaret
Support
Support

Hello,

I am not sure what would be the exact syntax for Qlik-Cli (which is just an abstraction layer on top of the Repository API by the way) but if you were to do it directly with the Repository API, then here is the syntax:

$body = '{
  "userDirectory":"DOMAIN",
  "userId":"user1a",
  "removedExternally":"false",
  "blacklisted":"false",
  "modifiedDate":"2021-02-12T14:00:36.157Z",
  "roles":[]
}'
$hdrs = @{}
$hdrs.Add("X-Qlik-xrfkey","12345678qwertyui")
   $hdrs.Add("X-Qlik-User","UserDirectory=INTERNAL;UserId=sa_repository")
   $cert = Get-ChildItem -Path "Cert:\CurrentUser\My" | Where {$_.Subject -like '*QlikClient*'}
$url = "https://qlikserver1.domain.local:4242/qrs/user/1cfb66b1-0fbc-4aa4-9cca-fb7450a6a83d?xrfkey=12345678qwertyui"
Invoke-RestMethod -Uri $url -Method Put -Headers $hdrs -ContentType 'application/json' -Certificate $cert -Body $body

  

If the issue is solved please mark the answer with Accept as Solution.