You can use QRS API to automate this process. There are few options. Easiest one would be using the Qlik Sense CLI (PowerShell). You can also use a Qlik Sense app and REST connector to perform this or built tool that can make REST calls.
To assign or remove you can use the following QRS endpoint -
Make a POST call to that API with ID = the user ID you are updating. You can use a user list/table to drive your allocation.
If the user never used Sense then you can perform a Delete operating on the following API -
We defined our directory connector criteria such that only users who are members of specific AD groups are retrieved. Some of these users are auto assigned licenses using license assignment rules based on group membership. To your de-allocation question, users that are removed from the AD groups defined in the directory connector are marked as "removed externally". It is then possible to use that status to identify and take action on license assignment. If you later re-add the user to the AD group, the "removed externally" flag is reset and a license is allocated automatically via the assignment rules (if de-allocation hasn't happened yet, the user never knows). 🙂 So far, this approach seems to provide what we need for auto license assignment and de-allocation. It's early and we may find some gotchas later, though. If anyone knows of any given what I've described here, please let me know! 😉