title: Export-Clixml converts a generic list to a standard array
body: <p>I use a <code>Collections.Generic.List[object]</code> instead of a PowerShell array in my script, in order to have ".add()" and also because of speed (the list is quite large).</p>
  
  <p>When I export the list via <a href="https://docs.microsoft.com/en-us/powershell/module/Microsoft.PowerShell.Utility/Export-Clixml?view=powershell-5.0" rel="nofollow noreferrer"><code>Export-Clixml</code></a> and reimport it again, it's not a generic-list any more; it's a standard array, and ".add()" does not work any more.</p>
  
  <p>Oddly (or not), when I place another generic list object inside the first one, it survives the export-import process.
  Why and how do I work around that?</p>
  
  <pre><code>$list = New-Object System.Collections.Generic.List[object]
  $entry = New-Object Psobject -Property @{
      Test = "1"
      Sublist = (New-Object System.Collections.Generic.List[object])
  }
  $list.add($entry)
  
  $list | Export-Clixml D:\text.xml
  $newlist = import-clixml D:\text.xml
  
  
  # Produces this export:
  
  *&lt;Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04"&gt;
    &lt;Obj RefId="0"&gt;
      &lt;TN RefId="0"&gt;
        &lt;T&gt;System.Management.Automation.PSCustomObject&lt;/T&gt;
        &lt;T&gt;System.Object&lt;/T&gt;
      &lt;/TN&gt;
      &lt;MS&gt;
        &lt;S N="Test"&gt;1&lt;/S&gt;
        &lt;Obj N="Sublist" RefId="1"&gt;
          &lt;TN RefId="1"&gt;
            &lt;T&gt;System.Collections.Generic.List`1[[System.Object, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]&lt;/T&gt;
            &lt;T&gt;System.Object&lt;/T&gt;
          &lt;/TN&gt;
          &lt;LST /&gt;
        &lt;/Obj&gt;
      &lt;/MS&gt;
    &lt;/Obj&gt;
  &lt;/Objs*&gt;
  </code></pre>