title: Pass variables to Foreach-Object PowerShell 7
body: <h2 id="what-i-want">What I want:</h2>
  <p>I have a script, which copies CAB-Files to over a hundred Servers, and works with it on them.
  This script runs for over a week.
  As I learned about the Foreach-Object -parallel Feature, I thought this would speed up the script considerably. But I ran into a problem. Since I am not very PowerShell knowledgeable, and I didn't find a post about this problem anywhere, I thought, I going to try my luck and ask here:</p>
  <h2 id="expected-and-actual-results">Expected and actual results</h2>
  <p>I want to pass a variable to the executed scriptblock in the foreach-object cmdlet, like here:</p>
  <pre><code>$test = &quot;123&quot;
  1..3|foreach-object -parallel {param($test);echo &quot;$_, $test&quot;} -ArgumentList($test)
  </code></pre>
  <p>What I expect:</p>
  <pre><code>1, 123
  2, 123
  3, 123
  </code></pre>
  <p>What I get:</p>
  <blockquote>
  <p>ForEach-Object: Parameter set cannot be resolved using the specified named parameters. One or more parameters issued cannot be used together or an insufficient number of parameters were provided.</p>
  </blockquote>
  <p>What am I doing wrong?</p>
  <p>It might be an trivial problem. But since I don't get anywhere and don't find any post/code example. I post it here. I am thankful for answers.</p>