The following BeanShell script can be used to bulk delete all non-admin users in a Liferay instance, including their groups, subscriptions, announcements, assets, blogs, etc.:
import com.liferay.portal.util.PortalUtil; import com.liferay.portal.service.UserLocalServiceUtil; import java.util.concurrent.*; pool = Executors.newFixedThreadPool(20); for (user : UserLocalServiceUtil.getUsers(0, 99999)) { if (user.isDefaultUser() || PortalUtil.isOmniadmin(user.getUserId())) { System.out.println("Skipping user " + user.getScreenName()); } else { final Object userToDelete = user; pool.execute(new Runnable() { public void run() { System.out.println("Deleting user " + userToDelete.getScreenName()); UserLocalServiceUtil.deleteUser(userToDelete); } }); } }
Paste this script into Control Panel > Server Administration > Scripts, with the “BeanShell” selected as the language.
Check the logs for the progress and/or errors.
* This is a backup post. The original has been deleted from: https://www.permeance.com.au/web/terry.mueller/profile/-/blogs/script-to-delete-liferay-users