title: Looping through a hash, or using an array in PowerShell
body: <p>I'm using this (simplified) chunk of code to extract a set of tables from SQL Server with <a href="https://en.wikipedia.org/wiki/Bulk_Copy_Program" rel="nofollow noreferrer">BCP</a>.</p>
  <pre><code>$OutputDirectory = 'c:\junk\'
  $ServerOption =   &quot;-SServerName&quot;
  $TargetDatabase = &quot;Content.dbo.&quot;
  
  $ExtractTables = @(
      &quot;Page&quot;
      , &quot;ChecklistItemCategory&quot;
      , &quot;ChecklistItem&quot;
  )
  
  for ($i=0; $i -le $ExtractTables.Length – 1; $i++)  {
      $InputFullTableName = &quot;$TargetDatabase$($ExtractTables[$i])&quot;
      $OutputFullFileName = &quot;$OutputDirectory$($ExtractTables[$i])&quot;
      bcp $InputFullTableName out $OutputFullFileName -T -c $ServerOption
  }
  </code></pre>
  <p>It works great, but now some of the tables need to be extracted via views, and some don't. So I need a data structure something like this:</p>
  <pre><code>&quot;Page&quot;                      &quot;vExtractPage&quot;
  , &quot;ChecklistItemCategory&quot;   &quot;ChecklistItemCategory&quot;
  , &quot;ChecklistItem&quot;           &quot;vExtractChecklistItem&quot;
  </code></pre>
  <p>I was looking at hashes, but I'm not finding anything on how to loop through a hash. What would be the right thing to do here? Perhaps just use an array, but with both values, separated by space?</p>
  <p>Or am I missing something obvious?</p>