Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6354407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:34:16+00:00 2026-05-24T22:34:16+00:00

I am trying to take PowerShell variables and apply them to a script block.

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T22:34:17+00:00Added an answer on May 24, 2026 at 10:34 pm

    You can pass values via the -arguments parameter and refer to them as $args[0] and so on inside the script block:

    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
    

    Or define the parameters inside the script block and use named parameters:

    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
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to write a powershell script that will take in a text
I am trying to take a String from a JTextField using getText and apply
I am trying to take the string <BR> in VB.NET and convert it to
I'm trying to take a numeric value in a string and raise it by
I am trying to take two numbers and get the square of them. Using
I'm trying to take a python class (in IronPython), apply it to some data
I am trying to take favicons and add them to a dynamic image that
I'm currently trying to take a string (0.1) and convert it to a double
I'm trying to take timestamps in this format: 2009-11-16T14:05:22-08:00 and make turn them into
I'm trying to take a jSON encoded string out of my database and loop

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.