title: Adding several objects of same type, to XML-file
body: <p>Is there a way to get commands that return several instances of same type object to get stored in each their variable?</p>
  
  <p>It's possible this ain't the best solution. What I'm dooing is gathering information from the computer and then saving it to a xml file.</p>
  
  <p>Take this:</p>
  
  <pre><code>gwmi -cn $compname Win32_UserAccount -filter 'LocalAccount=true' | foreach{$_.Name}
  </code></pre>
  
  <p>i want all the results placed in a xml file after this command has run, something like this:</p>
  
  <pre><code>$template = @"
  &lt;computer version='1.0'&gt;
    &lt;users&gt;
      &lt;user&gt;"HERE"&lt;/user&gt;
      &lt;user&gt;&lt;/user&gt;
    &lt;/users
  &lt;/computer&gt;
  "@
  </code></pre>
  
  <p>The tricky thing is that the number of objects will vary from computer to computer, but I want this script to make another <code>"&lt;user&gt;&lt;/user&gt;"</code>  for each object it finds and then place it there.</p>
  
  <p>All help will be appreciated!</p>