title: PowerCLI Get-VM output
body: <p>I am working on a script, and I am having trouble with a section of code.  When I pass in a list of computers that are all found in VCenter, the script populates the $result object correctly with a list of servers and all of the information included.  If there are any errors (unable to find server in VCenter) the only thing that is returned is the error line (in the case of multiple errors, only the last error is in $result).  Any ideas what I can do to resolve this?</p>
  
  <p>I know that it will work if I enclose the Get-VM statement in a foreach loop, but passing one server at a time to the VCenter takes a very long time.</p>
  
  <pre><code>try {
          $operation = Get-VM -Name $computers -ErrorAction Stop | Restart-VMGuest -Confirm:$false
          foreach ($comp in $operation) {
              $result += [pscustomobject] @{
                  Server = $computer
                  Status = $True
                  Error = $False
                  ErrorMessage = $null
                  Stamp = Get-Date
                  }
              }
          }
      catch {
          $result += [pscustomobject] @{
              Server = $computer
              Status = $False
              Error = $True
              ErrorMessage = $_
              Stamp = Get-Date
              }
          }
  </code></pre>