You can now vote for scripts to help people know if they're useful or not. Login or create an account to vote!

1

Retrieve List of Inactive Users

Overview

Retrieve an immutable list of inactive users from all projects, and convert to a List for ammendability functionality purposes.

Example

As a Jira administrator, I would like to identify and remove all inactive users across all projects I oversee. This script allows me to generate a list of all inactive users.
I can then use that list in conjunction with the Remove Users from Project Role script to remove all of the inactive users in the list I generated.

Requirements

  • Jira Jira (8.5 - 8.22)
  • ScriptRunner for Jira ScriptRunner for Jira (6.45.0)
    
import com.atlassian.jira.bc.user.search.UserSearchParams import com.atlassian.jira.bc.user.search.UserSearchService import com.atlassian.jira.component.ComponentAccessor def userSearchService = ComponentAccessor.getComponent(UserSearchService) final def limitValue = '' //Build a search with 100,000 results where users are inactive def userSearchBuilder = new UserSearchParams.Builder(limitValue) def userSearchParams = userSearchBuilder.allowEmptyQuery(true) .includeActive(false) .includeInactive(true) .limitResults(limitValue) .build() //Retrieve immutableList of Inactive Users def inactiveUsers = userSearchService.findUsers('', userSearchParams) //You can convert immutableList inactiveUsers, to a List with below //which is useful for method like ProjectRoleService.removeActorsFromProjectRole() def usersToRemove = [] as List inactiveUsers.each { usersToRemove.add(it.key.toString()) }
Discovered an issue? Report it here

Suggested for you