A small Selenium script for disabling a batch of Confluence users and removing their group memberships to free up licenses.
I recently wanted to clean up a batch of former employees from Confluence so we could free up some licenses. It turned out that Confluence did not seem to provide a built-in bulk cleanup feature, and the official REST API also did not expose a disable-user endpoint. So I ended up learning a bit of Selenium and wrote a small script to do it myself.
In Confluence, there are usually two ways to free up consumed licenses:
Disable the user
Remove the user from all groups
In most cases, simply disabling the user is enough. But if the same user exists in multiple user directories, such as both Confluence internal auth and external LDAP, then removing the user from all groups may still be necessary.
I wrote the following script and tested it with Confluence 7.11.0 and Chrome 88.
for user in USERS: status, msg = operator.disable_user(user) if status: status, msg = operator.remove_groups(user) if status: print(f'user [{user}] has been disabled and all groups removed') else: print(f'user [{user}] has been disabled but remove groups failed') else: print(f'user: [{user}] not exists') continue