blackberry - run - ssh session powershell
Pasar variables de Powershell a un scriptblock (1)
Estoy tratando de tomar variables de powershell y aplicarlas a un 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 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
Estoy corriendo
. / RandomActivationEmail.ps1 -username besadmin -password Pa $$ word -u bb.user
El error que estoy recibiendo es:
Invoke-Command: no se puede encontrar un parámetro posicional que acepte el argumento ''Pa $$ word''. En C: / Scripts / bb / RandomActivationEmail.ps1: 12 char: 15 + Invoke-Command <<<< -Sesión $ s -Scriptblock {cd "C: / Archivos de programa (x86) / Research In Motion / BlackBerry Enterprise Sever Resource Kit / BlackBerry Enterprise Server User Administration Tool Cliente "+ CategoryInfo: InvalidArgument: (:) [Invoke-Command], ParameterBindingException + FullyQualifiedErrorId: PositionalParameterNotFound, Microsoft.PowerShell.Commands.InvokeCommandCommand
Gracias por leer, saludó a Colm.
Puede pasar valores a través del parámetro -arguments y hacer referencia a ellos como $ args [0] y así sucesivamente dentro del bloque de script:
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 $args[0] -password $args[1] -ad_auth -domain staging -b bbbes -u $args[2] -change -wrandom
} -argumentlist $username $password $u
O define los parámetros dentro del bloque de script y usa parámetros con nombre:
Invoke-Command -Session $s -Scriptblock {
param(
$username,$password,$u
)
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