title: Export scriptblock from one file to be used in another file
body: <p>I have a scriptblock defined in <strong>a.psm1</strong> something as follows:</p>
  <pre><code>[scriptblock]$Script:Sb1 = {//somescript}
  </code></pre>
  <p>I am trying to use the scriptblock defined in <strong>a.psm1</strong> in another file <strong>b.psm1.</strong></p>
  <pre><code>$return = Invoke-Command -Session &quot;DC&quot; -Scriptblock $Script:Sb1
  </code></pre>
  <p>I am planning to export the scriptblock from <strong>a.psm1</strong> using function. I wanted to know if there's a better way to achieve this?</p>
  <p><em><strong>a.psm1:</strong></em></p>
  <pre><code>[scriptblock]$Script:Sb1 = {//somescript}
  
  function Startscriptblock{
          $sb = $Script:Sb1
          return $sb
      }
  Export-ModuleMember -Function Startscriptblock
  </code></pre>
  <p><em><strong>b.psm1:</strong></em></p>
  <pre><code>Import-Module a.psm1 
  $sb = Startscriptblock #get scriptblock in string form
  $sb = [scriptblock]::Create($sb) #Convert it into scriptblock type
  $return = Invoke-Command -Session &quot;DC&quot; -Scriptblock $sb
  </code></pre>