Print the hardware group members

vinod96
Tera Contributor

Print the hardware group members through script could you please help any one.

2 REPLIES 2

SN_Learn
Kilo Patron
Kilo Patron

Hi @vinod96 ,

 

Please try the below script:

var grpMembers = new GlideRecord('sys_user_grmember');
// '8a5055c9c61122780043563ef53438e3'  - sysID of 'Hardware" group
grpMembers.addQuery('group','8a5055c9c61122780043563ef53438e3');
grpMembers.query();
while(grpMembers.next())
{
gs.info(grpMembers.user.name);
}

 

Output:

 

*** Script: David Dan
*** Script: Beth Anglin
*** Script: Fred Luddy
*** Script: David Loo
*** Script: ITIL User
*** Script: Don Goodliffe
*** Script: Bow Ruggeri

 

Please mark this as correct answer and helpful if it resolved, or mark this helpful if this help you to reach towards solution.

----------------------------------------------------------------
Mark this as Helpful / Accept the Solution if this helps.

Danish Bhairag2
Tera Sage
Tera Sage

Hi @vinod96 ,

 

U can use the below code to retrieve the members from a group.

 

var members = [];
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('group','287ebd7da9fe198100f92cc8d1d2154e');
gr.query();
while(gr.next()){
members.push(gr.user.name.toString());
}
gs.info(members);

 

Please mark my answer helpful & accepted if it helps you resolve your query.

 

Thanks,

Danish