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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


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

Need script to remove 60-day inactive users from jira-users group

I am not a strong script writer so I am looking for someone to provide me a script that I can run each night to look for users who have not logged in in the last 60 days and remove them from the jira-users group so they no longer take a license up.  I have ScriptRunner. I have found other scripts out there to de-activate users, but those scripts don't work for me because of our AD/LDAP setup.  So I just want to remove the inactive from the jira-users group.  I would be SO GREATFUL for someone to provide me a script to do this by username.  We have Jira 8.19.

3 answers

1 accepted

0 votes
Answer accepted

@Mirco Fabbri Provided the answer in a different write up: 

 Here is the script he provided...

import com.atlassian.jira.component.ComponentAccessor
import java.text.SimpleDateFormat;
import com.atlassian.crowd.embedded.api.CrowdService
import com.atlassian.crowd.embedded.api.UserWithAttributes
import com.atlassian.jira.bc.user.UserService
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.event.type.EventDispatchOption

def userUtil = ComponentAccessor.userUtil
def userManager = ComponentAccessor.userManager
def groupManager = ComponentAccessor.getGroupManager();
def loginManager = ComponentAccessor.getComponentOfType(LoginManager.class)
CrowdService crowdService = ComponentAccessor.crowdService
def maxDays = 90 // maximum number of days you will allow


def excludedGroups = [ // only externals


long count = 0;
def list
def lastlogin
def output = "Display Name; Username; Email; Last Login <br>"
def today = new Date()
def lastLogin
SimpleDateFormat df = new SimpleDateFormat("dd.MM.yy hh:mm")
userManager.getUsers().each { // loop through every user
list = true;
groupManager.getGroupNamesForUser(it).each { // loop through his groups
if (excludedGroups.contains(it)) { // if at least one group is in the list, add user
list = false;
if(list && it.isActive()) { //check if user is active & supposed to be listed
UserWithAttributes user = crowdService.getUserWithAttributes(it.getName())
Long lastLoginTime = loginManager.getLoginInfo(it.username).getLastLoginTime()
lastlogin = "Never Logged In"
if(lastLoginTime != null) {
Date date = new Date(lastLoginTime)
lastlogin = df.format(date)
if(lastLoginTime != null && groovy.time.TimeCategory.minus(new Date(), new Date(lastLoginTime)).days > maxDays) {
userUtil.removeUserFromGroup(ComponentAccessor.groupManager.getGroup("jira-software-user"), it)
output += "${it.getDisplayName()}; ${it.getUsername()}; ${it.getEmailAddress()}; ${lastlogin};<br>"

Hi @kdickason 
Glad you asked this,

you can consider using the miniOrange Bulk User management plugin for JIRA.
There, you can find a variety of features regarding user management such as deactivating inactive users (the same requirement you have), you can also perform bulk operations on the users (which native Jira user management does not support) You can import or export users and auto deactivate users who have never logged in. On top of that, if you need
any custom features, we also provide tailor-made solutions just for your requirements.
Check out the plugin here.

1 vote
Fazila Ashraf
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Oct 26, 2021

Hi @kdickason 

You can refer to and tweek it for removing the users from the group jira-users 

To get the inactive users, as mentioned in the page, you can refer to to get the list of users with some more tweeks.

Hi @Fazila Ashraf ,

Is it possible to get inactive users in Jira Cloud using the script Runner addon?


Prasad E

Like Olivia Case likes this
Fazila Ashraf
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Jan 17, 2022

Haven't done that in cloud but a quick search got me this free plugin that could help with this use case


Hope it helps... Let me know

Hi @Prasad Eda ,

Did you find/created the script to inactive users in Jira Cloud using the script Runner addon? 

I am also looking for the same in Jira cloud using Script Runner.



Like Olivia Case likes this

Same - looking for this Jira Cloud version of the Script Runner code. 


Looking through Adaptavist library there aren't many scripts for the cloud. 

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Dec 29, 2022

You can't do this in Jira Cloud - users and groups are maintained in Atlassian Access, or Atlassian Admin if you don't have Access.  You would need to look for a solution that can do site admin.

Like Alok Kumar likes this

Darn - thanks Nic.

Like Nic Brough -Adaptavist- likes this

Hi @Olivia Case

If you're looking for an easy way to automatically deactivate inactive users, you can install this app from the marketplace:

Auto Users Management 


It will deactivate all inactive users you have periodically by the time you choose.

It's secure and uses Atlassian's Api's only

Suggest an answer

Log in or Sign up to answer