title: Passing Powershell variables into a scriptblock
body: <p>I am trying to take powershell variables and apply them to a scriptblock. </p>
  
  <pre><code>param(
      [string]$username = $(throw "Blackberry Admin User Name is required"),
      [string]$password = $(throw "Blackberry Admin Password is required"),
      [string]$u = $(throw "Blackberry User Name is required")
      )
  
  $s = New-PSSession -computerName bbbes01 
  Invoke-Command -Session $s -Scriptblock {cd "C:\Program Files (x86)\Research In Motion\BlackBerry Enterprise Server Resource Kit\BlackBerry Enterprise Server User Administration Tool Client"
  ./BESUserAdminClient -username $username -password $password -ad_auth -domain staging -b bbbes -u $u -change -wrandom} -argumentlist $username $password $u
  </code></pre>
  
  <p>I am running </p>
  
  <blockquote>
    <p>.\RandomActivationEmail.ps1 -username besadmin -password Pa$$word -u bb.user</p>
  </blockquote>
  
  <p>The error that I am getting is:-</p>
  
  <blockquote>
    <p>Invoke-Command : A positional parameter cannot be found that accepts argument 'Pa$$word'.
    At C:\Scripts\bb\RandomActivationEmail.ps1:12 char:15
    + Invoke-Command &lt;&lt;&lt;&lt;  -Session $s -Scriptblock {cd "C:\Program Files (x86)\Research In Motion\BlackBerry Enterprise Se
    rver Resource Kit\BlackBerry Enterprise Server User Administration Tool Client"
        + CategoryInfo          : InvalidArgument: (:) [Invoke-Command], ParameterBindingException
        + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.InvokeCommandCommand</p>
  </blockquote>
  
  <p>Thanks for reading, cheers Colm.</p>