title: How to use a string value in foreach?
body: <p>How to use a string value in foreach?</p>
  
  <p>The following works.</p>
  
  <pre><code>$printString='$_.name+","+$_.name'
  Get-ChildItem|foreach {$_.name+','+$_.name}
  </code></pre>
  
  <p><strong>But the following doesn't work</strong></p>
  
  <pre><code>Get-ChildItem|foreach {$printString}
  </code></pre>
  
  <p>But I need it to work: because I have a task to print each column in a table, I can use table dictionary to get all the columns, so all are dynamic, and then when I try to print the result, I also use a string like above to print the result. Any solution</p>