title: PowerShell: I cannot get $DataSet.Tables[0].rows into an array of strings, with no headers
body: <p>I have this to query SQL from powershell:</p>
  
  <pre><code>PARAM([String] $env_code, [String] $db_server)
  
  $connectionString = "ConnectTheShizz"
  $connection = new-object system.data.SqlClient.SQLConnection($connectionString)
  $sqlCommand = "SELECT Yada FROM YadaYada"
  
  $command = new-object system.data.sqlclient.sqlcommand($sqlCommand,$connection)
  $connection.Open()
  
  $adapter = New-Object System.Data.sqlclient.sqlDataAdapter $command
  $dataset = New-Object System.Data.DataSet
  $adapter.Fill($dataSet) | Out-Null
  
  $connection.Close()
  
  $strStuff = $DataSet.Tables[0].rows| ft -HideTableHeaders
  </code></pre>
  
  <p>I am not sure what $strStuff is (what DataType it is or whatever). If I just print it out to the console, I get what looks like an array of ints (though in the DB, these are strings, so I am not sure if that is what they are coming back as):</p>
  
  <pre><code>$strStuff
  0003128                                                                        
  0005588                                                                        
  0016308                                                                        
  0021216
  ...     
  </code></pre>
  
  <p>But if I attempt to make them strings:</p>
  
  <pre><code>$strStuff | ForEach-Object {$_.ToString()}
  Microsoft.PowerShell.Commands.Internal.Format.FormatStartData
  Microsoft.PowerShell.Commands.Internal.Format.GroupStartData
  Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData
  Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData
  ...
  </code></pre>
  
  <p>If I just assume they are strings, and try to roll on down the road, I get this:</p>
  
  <pre><code>$strCusips -join ','
  Microsoft.PowerShell.Commands.Internal.Format.FormatStartData,Microsoft.PowerShell.Commands.Internal.Format.GroupStartData,Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData,Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData,...
  </code></pre>
  
  <p>EDIT:</p>
  
  <p>To be clearer, this is what I have:</p>
  
  <pre><code>0003128                                                                        
  0005588                                                                        
  0016308                                                                        
  0021216
  ...    
  </code></pre>
  
  <p>This is what I want (a single, comma-separated string):</p>
  
  <pre><code>0003128,0005588,0016308,0021216,...
  </code></pre>
  
  <p>EDIT 2:</p>
  
  <p>Using <code>.GetType()</code> I get this:</p>
  
  <pre><code>IsPublic IsSerial Name                                     BaseType            
  -------- -------- ----                                     --------            
  True     True     Object[]                                 System.Array  
  </code></pre>
  
  <p><code>| Get-Member</code> does this:</p>
  
  <pre><code>   TypeName: Microsoft.PowerShell.Commands.Internal.Format.FormatStartData
  Name                                    MemberType Definition                  
  ----                                    ---------- ----------                  
  Equals                                  Method     bool Equals(System.Object...
  GetHashCode                             Method     int GetHashCode()           
  GetType                                 Method     type GetType()              
  ToString                                Method     string ToString()           
  autosizeInfo                            Property   Microsoft.PowerShell.Comm...
  ClassId2e4f51ef21dd47e99d3c952918aff9cd Property   string ClassId2e4f51ef21d...
  groupingEntry                           Property   Microsoft.PowerShell.Comm...
  pageFooterEntry                         Property   Microsoft.PowerShell.Comm...
  pageHeaderEntry                         Property   Microsoft.PowerShell.Comm...
  shapeInfo                               Property   Microsoft.PowerShell.Comm...
     TypeName: Microsoft.PowerShell.Commands.Internal.Format.GroupStartData
  Name                                    MemberType Definition                  
  ----                                    ---------- ----------                  
  Equals                                  Method     bool Equals(System.Object...
  GetHashCode                             Method     int GetHashCode()           
  GetType                                 Method     type GetType()              
  ToString                                Method     string ToString()           
  ClassId2e4f51ef21dd47e99d3c952918aff9cd Property   string ClassId2e4f51ef21d...
  groupingEntry                           Property   Microsoft.PowerShell.Comm...
  shapeInfo                               Property   Microsoft.PowerShell.Comm...
     TypeName: Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData
  Name                                    MemberType Definition                  
  ----                                    ---------- ----------                  
  Equals                                  Method     bool Equals(System.Object...
  GetHashCode                             Method     int GetHashCode()           
  GetType                                 Method     type GetType()              
  ToString                                Method     string ToString()           
  ClassId2e4f51ef21dd47e99d3c952918aff9cd Property   string ClassId2e4f51ef21d...
  formatEntryInfo                         Property   Microsoft.PowerShell.Comm...
  outOfBand                               Property   bool outOfBand {get;set;}   
  writeStream                             Property   Microsoft.PowerShell.Comm...
     TypeName: Microsoft.PowerShell.Commands.Internal.Format.GroupEndData
  Name                                    MemberType Definition                  
  ----                                    ---------- ----------                  
  Equals                                  Method     bool Equals(System.Object...
  GetHashCode                             Method     int GetHashCode()           
  GetType                                 Method     type GetType()              
  ToString                                Method     string ToString()           
  ClassId2e4f51ef21dd47e99d3c952918aff9cd Property   string ClassId2e4f51ef21d...
  groupingEntry                           Property   Microsoft.PowerShell.Comm...
     TypeName: Microsoft.PowerShell.Commands.Internal.Format.FormatEndData
  Name                                    MemberType Definition                  
  ----                                    ---------- ----------                  
  Equals                                  Method     bool Equals(System.Object...
  GetHashCode                             Method     int GetHashCode()           
  GetType                                 Method     type GetType()              
  ToString                                Method     string ToString()           
  ClassId2e4f51ef21dd47e99d3c952918aff9cd Property   string ClassId2e4f51ef21d...
  groupingEntry                           Property   Microsoft.PowerShell.Comm...
  </code></pre>