You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
Hi,
I have some regular user management clean up where I need to remove a list of users from all the groups that they are in. Jira server v7 and using ScriptRunner Script Console. Can anyone help?
Much appreciated
Hi @Peter Ellis,
this script uses the Jira API 7.6.1 and worked on my system (Jira Server 7.9).
import com.atlassian.jira.component.ComponentAccessor
List<String> userNames = ["testuser"] // add all usernames in this array where you want to remove the groups
def userUtil = ComponentAccessor.getUserUtil()
def userManager = ComponentAccessor.getUserManager()
for (String userName in userNames) {
def groups = userUtil.getGroupsForUser(userName)
def user = userManager.getUserByName(userName)
for (def group in groups) {
userUtil.removeUserFromGroup(group, user)
}
}
With kind regards,
Mario
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Peter Ellis,
good idea to create a script for this usecas!
I will use this myself :)
With kind regards
Mario
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Mario
nice script:-)
Due to performance reasons I modified it as shown... (changed removeUserFromGroup to removeUserFromGroups)
import com.atlassian.jira.component.ComponentAccessor
List<String> userNames = ["TestUser"] // add all usernames in this array where you want to remove the groups
def userUtil = ComponentAccessor.getUserUtil()
def userManager = ComponentAccessor.getUserManager()
for (String userName in userNames) {
def groups = userUtil.getGroupsForUser(userName)
def user = userManager.getUserByName(userName)
userUtil.removeUserFromGroups(groups, user)
}
Cheers
Heiko
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Heiko Gerlach and @Mario Carabelli
I need the help in this question : https://community.atlassian.com/t5/Jira-questions/Get-and-remove-all-groups-from-User-in-Crowd/qaq-p/2158148
you can help me please
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.