Print the hardware group members
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-01-2023 05:45 AM
Print the hardware group members through script could you please help any one.
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-01-2023 06:00 AM
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.
Mark this as Helpful / Accept the Solution if this helps.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-01-2023 06:12 AM
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