dump ServiceNow group membership

Dump group membership

 var groupName = 'CTS STC Cluster Zone 1';
 var gr = new GlideRecord('sys_user_group');
 gr.addQuery('name', 'CTS STC Cluster Zone 1');
 gr.query();gr.next();
 var gr_sysid = gr.sys_id;
 var g = new GlideRecord('sys_user_grmember');
  g.addQuery('group', gr_sysid);
  g.query();
  var n=0;
  while (g.next()) {
     if (n == 0 ) {
       gs.print('members are: ');
     }
     gs.print(g.user.user_name + ';');
     n++;
  }
  gs.print(n + " members in group");

Now parse it into something useful for going back into AD

*** Script: members are: 
*** Script: jfo8;
*** Script: dkb23;
*** Script: fc265;
*** Script: ak764;
*** Script: yx97;
*** Script: dlp54;
*** Script: djy6;
*** Script: gmh29;
*** Script: mdw55;
*** Script: bmm44;
*** Script: ncx2;
*** Script: xn6;
*** Script: jt487;
*** Script: blr33;
*** Script: rc527;
*** Script: jcw84;
*** Script: bmw32;
*** Script: dam78;
*** Script: dcj23;
*** Script: lab224;
*** Script: jww39;
*** Script: jkt24;
*** Script: ay222;
*** Script: jl2377;
*** Script: jlf8;
*** Script: xy63;
*** Script: mg828;
*** Script: cap32;
*** Script: dsf3;
*** Script: yw355;
*** Script: ooo9;
*** Script: csw3;
*** Script: ak;
*** Script: yb45;
*** Script: sbo2;
*** Script: dz65;
*** Script: rrm3;
*** Script: 37 members in group

Bash script

[db692@radar ~]$ cat asdf | grep -v member | cut -d' ' -f3 | sed ':a;N;$!ba;s/\n//g'
jfo8;dkb23;fc265;ak764;yx97;dlp54;djy6;gmh29;mdw55;bmm44;ncx2;xn6;jt487;blr33;rc527;jcw84;bmw32;dam78;dcj23;lab224;jww39;jkt24;ay222;jl2377;jlf8;xy63;mg828;cap32;dsf3;yw355;ooo9;csw3;ak;yb45;sbo2;dz65;rrm3;