Ad-Hoc Group Wizard

(imported topic written by MBARTOSH)

I have a custom wizard call Ad-hoc Group Wizard. This wizard opens a box where you paste in a list of computer names. It then displays the computers with all the properties in the console. I have pasted in the code.

My question is: does anyone have a similar wizard or know how to modify this wizard to create a list of computers based on the “last logged on user”?

<?xml version="1.0"?>
<Title>Ad-Hoc Group Wizard</Title>

<DefaultPage>Page1</DefaultPage>


<Page Name="Page1">


  <Title>Ad-Hoc Group Wizard</Title>


  <HTML>


    <![CDATA[


 


 <table>


  <tr>


   <td>


    Paste the list of hostnames below:


    <br/>


    <textarea id="hostnames" rows=20 cols=60 ></textarea>


   </td>


   <td id="errorTD"  style="display: none">


    Errors:


    <br/>


    <textarea rows=20 cols=60 id="errorField"></textarea>


   </td>


  </tr>


 </table>


 <br />


 <button onclick="openGroup()">Open Ad-Hoc Group</button>


 <script type="text/javascript">


 function openGroup()


 {


  var names = hostnames.value.split('\n');


  var ids = new Array();


  var errs = new Array();


  errorField.value = '';


  errorTD.style.display = 'none';


   


  for (var i = 0; i< names.length; i++)


  {


   var rel = 'ids of bes computers whose (name of it as lowercase = "'+ chomp(names[i].toLowerCase()) + '")';


   var id = EvaluateRelevance(rel);


   if (id && id.length == 1)


   {


    ids.push(id);


   }


   else if (id && id.length > 1)


   {


    ids = ids.concat(id);


   }


   else


   {


    errs.push(chomp(names[i].toLowerCase()));


   }


  }


  if (errs.length > 0)


  {


   errorField.value = errs.join('\n');


   errorTD.style.display = '';


  }


  OpenComputerGroup(ids);


 }


 


 function chomp(raw_text)


 {


   return raw_text.replace(/(\n|\r)+$/, '');


 }


 </script>     


]]>     
</Page>

(imported comment written by BrianPGreen)

I suppose you want to use the “User Name” property? That’s probably the best approximation of the “last logged on user”, though maybe there’s something better. At any rate, if you want to use a different property, you can follow the same pattern. The relevance changes to be this:

‘ids of bes computers whose (exists values whose (it as lowercase = "’+ chomp(names[i].toLowerCase()) + ‘") of result from ( bes property whose ( name of it = “User Name” ) ) of it )’;

And the new wizard is this:

<?xml version="1.0"?>
<Title>Ad-Hoc Group Wizard</Title>

<DefaultPage>Page1</DefaultPage>



<Page Name="Page1">



  <Title>Ad-Hoc User Wizard</Title>



  <HTML>



    <![CDATA[



 



 <table>



  <tr>



   <td>



    Paste the list of users below:



    <br/>



    <textarea id="users" rows=20 cols=60 ></textarea>



   </td>



   <td id="errorTD"  style="display: none">



    Errors:



    <br/>



    <textarea rows=20 cols=60 id="errorField"></textarea>



   </td>



  </tr>



 </table>



 <br />



 <button onclick="openGroup()">Open Ad-Hoc Group</button>



 <script type="text/javascript">



 function openGroup()



 {



  var names = users.value.split('\n');



  var ids = new Array();



  var errs = new Array();



  errorField.value = '';



  errorTD.style.display = 'none';



   



  for (var i = 0; i< names.length; i++)



  {



   var rel = 'ids of bes computers whose (exists values whose (it as lowercase = "'+ chomp(names[i].toLowerCase()) + '") of result from ( bes property whose ( name of it = "User Name" ) ) of it )';



   var id = EvaluateRelevance(rel);



   if (id && id.length == 1)



   {



    ids.push(id);



   }



   else if (id && id.length > 1)



   {



    ids = ids.concat(id);



   }



   else



   {



    errs.push(chomp(names[i].toLowerCase()));



   }



  }



  if (errs.length > 0)



  {



   errorField.value = errs.join('\n');



   errorTD.style.display = '';



  }



  OpenComputerGroup(ids);



 }



 



 function chomp(raw_text)



 {



   return raw_text.replace(/(\n|\r)+$/, '');



 }



 </script>     



]]>     
</Page>

(imported comment written by MBARTOSH)

Is there a way to speed this up? It is quite slow. It is fast when just using the computer name.

(imported comment written by BrianPGreen)

I’m sorry, since we’re not using the same deployment, I’m not sure why it’s slow on your deployment. If I were in your position, I would try looking at it in the “Presentation Debugger” in the console to mess around with the relevance to try to guess at what’s slow.