title: PowerShell array to store strings
body: <p>I have a list of files that I am breaking up into parts. That works, but I want to be able to reference each part individually. The issue is with my array not wanting/being able to take in a string. The file naming format is custID_invID_prodID or custID_invID_prodID_Boolvalue.</p>
  
  <pre><code>$files = Get-ChildItem test *.txt
  [string]$custId = $files.Count
  [string]$invID = $files.Count
  [string]$prodID = $files.Count
  [int]$Boolvalue = $files.Count
  foreach($file in (Get-ChildItem test *.txt)) {
      for($i = 0; $i -le $files.Count; $i++){
          $custId[$i], $invID[$i], $prodID[$i], $Boolvalue[$i] = $file.BaseName -split "_"
          Write-Host $custId, $invID, $prodID, $Boolvalue
      }
  }
  </code></pre>
  
  <p>The error message I am seeing is:</p>
  
  <blockquote>
    <p>Unable to index into an object of type System.String.</p>
  </blockquote>
  
  <p>How can I do this?</p>