Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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 Apps & Integrations

🍻🍂Apptoberfest Update: Upcoming Virtual Events 🎉

Hello Community! I hope you've been enjoying the 🍂Apptoberfestivities🍂 (I know I have!) The event is heating up next week with a series of virtual events that we're calling the 🍻🍂Partner App ...

157 views 2 14
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