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

grovy script for list of active and inactive users

Hi all can anyone please help me with the script for getting the list of users in jira  Name, Email Address, and active and in active users list and created , last updated date in a single script? is that possible to get all these details in a single script? please help me in this thank you in advance 

1 answer

Hi @Murthy Dusanapudi 

Run below Script in Script console. 

in Status column :- False means inactive user and true means active user. 


import com.atlassian.jira.component.ComponentAccessor
import java.text.SimpleDateFormat;
import java.util.Date;
import com.atlassian.jira.user.util.UserUtil
UserUtil userUtil = ComponentAccessor.getUserUtil()
def loginManager = ComponentAccessor.getComponentOfType(LoginManager.class)
def users=ComponentAccessor.getUserUtil().getUsers()
StringBuilder builder=new StringBuilder()
builder.append("<table border = 1><tr><td><b>User Name</b></td><td><b>Full Name</b></td><td><b>eMail Address</b></td><td><b>Last Login</b></td><td><b>Status</b></td><td><b>Group</b></td></tr>")
Long lastLoginTime = loginManager.getLoginInfo(it.username).getLastLoginTime()
builder.append("<tr><td>"+it.username+"</td><td>"+it.displayName+"</td><td>"+it.emailAddress+"</td><td>Inactive User</td><td>""</td></tr>")
else if(lastLoginTime==null)
builder.append("<tr><td>"+it.username+"</td><td>"+it.displayName+"</td><td>"+it.emailAddress+"</td><td>Logon not found</td><td>""</td></tr>")
else if(userUtil.getGroupsForUser(it.getName()).size() == 0)
builder.append("<tr><td>"+it.username+"</td><td>"+it.displayName+"</td><td>"+it.emailAddress+"</td><td>No Group added</td><td>""</td></tr>")
Date date=new Date(lastLoginTime);
SimpleDateFormat df2 = new SimpleDateFormat("dd/MM/yy hh:mm");
String dateText = df2.format(date);

return builder

Hi @Vikrant Yadav its working now tnq soo much for the script ...and how can i get these details in confluence?

Cool! Glad to hear it works for you. 

For Confluence i am not sure, we dont have Script Runner installed in Confluence. 

Start new Conversation in Atlassian Community for Confluence.  


the script is not returning last logon for the active/true users also not returning groups the user belongs to.

Would be able to work on your query? as it is really good one... also want to find out how to automate this to run every 30days or 90days... as a scheduled job. that would be very much helpful.

Suggest an answer

Log in or Sign up to answer
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,129 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