title: Powershell array containing array
body: <p>I am learning PowerShell (newbie alert!!) and am trying to figure out why the following strange behavior is seen. (Environment : Windows 10 with PowerShell 5)</p>
  
  <pre><code>C:\&gt;POWERSHELL
  Windows PowerShell
  Copyright (C) 2015 Microsoft Corporation. All rights reserved.
  
  PS &gt; $A=(1,2,3) # When a variable stores a new array, ...
  PS &gt; $A # the elements are shown correctly.
  1
  2
  3
  PS &gt; $B=$A # When the array is copied, ...
  PS &gt; $B # the elements are shown correctly.
  1
  2
  3
  PS &gt; $B=($A,4,5,6) # When the variable stores a new array with elements from some other array ...
  PS &gt; $B # the elements are shown correctly.
  1
  2
  3
  4
  5
  6
  PS &gt; $B=($B,7,8,9) # But, when the variable stores a new array with elements from the array currently stored in the same variable, ...
  PS &gt; $B # something strange is seen
  
  
  Length         : 3
  LongLength     : 3
  Rank           : 1
  SyncRoot       : {1, 2, 3}
  IsReadOnly     : False
  IsFixedSize    : True
  IsSynchronized : False
  Count          : 3
  
  4
  5
  6
  7
  8
  9
  
  
  PS &gt;
  </code></pre>
  
  <p><strong>Any pointers on what is going on ?</strong></p>
  
  <p>While typing this question, I was trying to analyze the situation. The way I see it:<br>
  <code>$B=($A,4,5,6)</code> makes $B an array with an array element.<br>
  <code>$B=($B,7,8,9)</code> makes $B an array with an array element with an array element.<br>
  The PowerShell CLI function which shows the variable contents, does not go all the way down to the leaf elements, but stops at the second level.<br>
  Hence the inner most array (contents==$A) is shown as some object.<br>
  <strong>Is this explanation correct ?</strong></p>