I am trying to take powershell variables and apply them to a scriptblock.
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 MotionBlackBerry Enterprise Server Resource KitBlackBerry 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:ScriptsbRandomActivationEmail.ps1:12 char:15 + Invoke-Command <<<< -Session $s -Scriptblock {cd "C:Program Files (x86)Research In MotionBlackBerry Enterprise Se rver Resource KitBlackBerry Enterprise Server User Administration Tool Client" + CategoryInfo : InvalidArgument: (:) [Invoke-Command], ParameterBindingException + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.InvokeCommandCommand
Thanks for reading, cheers Colm.
See Question&Answers more detail:os