Hello all,
We got several spam accounts in our internal directory with same full name. We need to bulk delete all of them.
Is there a way we could get list of Users using full name and deleting them using a loop in ScriptRunner?
Hello @kiran kumar
Try the following
import com.atlassian.jira.bc.user.UserServiceimport com.atlassian.jira.bc.user.search.UserSearchServiceimport com.atlassian.jira.component.ComponentAccessordef userServise = ComponentAccessor.getComponent(UserService)def userSearchServise = ComponentAccessor.getComponent(UserSearchService)def adminUser = ComponentAccessor.userManager.getUserByName('AdminUserName')def users = userSearchServise.findUsersByFullName('FullName')users.each {def result = userServise.validateDeleteUser(adminUser, it)if (result.valid) userServise.removeUser(adminUser, result)}
Thanks a lot, Yuri!
Just one correction, getUserByName did not work, so I have used getUserByKey.
It looks like you're new here. Sign in or register to get started.