I am trying to take PowerShell variables and apply them to a script block.
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
I am running
.\RandomActivationEmail.ps1 -username besadmin -password Pa$$word -u bb.user
The error that I am getting is:
Invoke-Command : A positional parameter cannot be found that accepts argument 'Pa$$word'. At C:\Scripts\bb\RandomActivationEmail.ps1:12 char:15
+ 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"
+ CategoryInfo : InvalidArgument: (:) [Invoke-Command], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.InvokeCommandCommand