Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Inactivate jira user automatically via scriptrunner

Need an exact script to inactive the jira users.

we have the users to be inactive in a list and the list of users is to be inactive.


1 comment

Adaptavist has a script documented here that will deactivate idle users:


Just be sure to test this in a lower environment before deactivating users in production.

Like Suji Shyam likes this

Also a tried a script to inactive the users.

One can run this script in the scriptrunner console and get the users inactivated. Successfully got the result.

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.crowd.embedded.api.User
import com.atlassian.crowd.embedded.impl.ImmutableUser
import com.atlassian.jira.bc.user.UserService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.util.UserManager
import com.atlassian.jira.user.ApplicationUsers
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.crowd.embedded.api.CrowdService
import com.atlassian.crowd.embedded.api.UserWithAttributes

UserSearchService userSearchService = ComponentAccessor.getComponent(UserSearchService.class);
UserSearchParams userSearchParams = new UserSearchParams(true, true, false);
//String pattern = ""
List<ApplicationUser> userList = userSearchService.findUsers("","", userSearchParams);
def namePrint = ""
//namePrint += it.displayName
namePrint += + "<br>"
// return namePrint.split("<br>") // [appuser242, appuser245, jegi01, sankesw]
String[] nameofactive = namePrint.split("<br>")
int i
for (i=0; i<=nameofactive.size(); i++)
CrowdService crowdService = ComponentAccessor.crowdService
UserWithAttributes user = crowdService.getUserWithAttributes(nameofactive[i]);
UserService userService = ComponentAccessor.getComponent(UserService)
ApplicationUser updateUser = ApplicationUsers.from(ImmutableUser.newUser(user).active(false).toUser());
UserService.UpdateUserValidationResult updateUserValidationResult = userService.validateUpdateUser(updateUser)

if (updateUserValidationResult.isValid()) {


} else {
log.error "Update of ${} failed: ${updateUserValidationResult.getErrorCollection().getErrors().entrySet().join(',')}";




Log in or Sign up to comment
Community showcase
Published in Jira Software

Upcoming changes to epic fields in company-managed projects

👋 Hi there Jira Community! A few months ago we shared with you plans around renaming epics in your company-managed projects. As part of these changes, we highlighted upcoming changes to epics on...

14,130 views 34 44
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you