title: How to initialize an array of custom objects
body: <p>First, as this leads to my question, I'll start by noting that I've worked with XML a fair bit in PowerShell, and like how I can read data from XML files, quickly, into arrays of custom objects. For example, if I had the following XML file:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;stuff&gt;
   &lt;item name="Joe" age="32"&gt;
    &lt;info&gt;something about him&lt;/info&gt;
   &lt;/item&gt;
   &lt;item name="Sue" age="29"&gt;
    &lt;info&gt;something about her&lt;/info&gt;
   &lt;/item&gt;
   &lt;item name="Cat" age="12"&gt;
    &lt;info&gt;something else&lt;/info&gt;
   &lt;/item&gt;
  &lt;/stuff&gt;
  </code></pre>
  
  <p>And if I read it in simply, like this:</p>
  
  <pre class="lang-bash prettyprint-override"><code>[xml]$myxml = Get-Content .\my.xml
  </code></pre>
  
  <p>Then I can get to an array of my items like this:</p>
  
  <pre class="lang-none prettyprint-override"><code>[array]$myitems = $myxml.stuff.Item
  $myitems
  
  name   age  info
  ----   ---  ----
  Joe    32   something about him
  Sue    29   something about her
  Cat    12   something else
  </code></pre>
  
  <p>So, now my question:</p>
  
  <p><strong>How can I create a similar structure of an array of custom objects, and initialize them in my script, <em>without</em> reading a file?</strong></p>
  
  <p>I can do lots of looping and/or lots of creating/initializing individual objects, and then add to an array one at a time...</p>
  
  <p>But it seems there should be a way to perform this creation/initialization in a simpler way.  Note that the key here, is that my custom objects have more than two elements (otherwise, I'd have used a hash).</p>
  
  <p>I've even looked at creating a big string of XML, and using Select-XML, but I just couldn't get the syntax right (if that was even the right road to be heading down).</p>