title: How do I pass a scriptblock as one of the parameters in start-job
body: <p>I'm trying to create a background job, which executes a scriptblock. I need to pass this scriptblock in as a parameter, but I can't seem to get the syntax to work. The scriptblock is being converted to a string somewhere along the way.</p>
  <p>It works fine when I pass the script block to a local function, but not through start-job</p>
  <p>The following syntax works:</p>
  <pre><code>function LocalFunction
  {
      param (
          [parameter(Mandatory=$true)]
          [ScriptBlock]$ScriptBlock
      )
  
      &amp;$ScriptBlock | % { echo &quot;got $_&quot; }
  }
  
  LocalFunction -ScriptBlock { echo &quot;hello&quot; }
  </code></pre>
  <p>This outputs &quot;got hello&quot; as expected.</p>
  <p>But the following fails:</p>
  <pre><code>$job = start-job -argumentlist { echo &quot;hello&quot; } -scriptblock {
      param (
          [parameter(Mandatory=$true)]
          [ScriptBlock]$ScriptBlock
      )
      &amp;$ScriptBlock | % { echo &quot;got $_&quot; }
  }
  start-sleep -s 1
  receive-job $job
  </code></pre>
  <p>The error it returns is</p>
  <pre><code>Receive-Job : Cannot process argument transformation on parameter 'ScriptBlock'. Cannot convert the &quot; echo &quot;hello&quot; &quot; value of type &quot;System.String&quot; to type &quot;System.Management.Automation.ScriptBlock&quot;.
  </code></pre>
  <p>So if I'm reading the error right, it appears that -argumentlist is somehow forcing its arguments into strings.</p>