# Pass parameter in invoke-command

**URL:** <https://forums.powershell.org/t/pass-parameter-in-invoke-command/13790>\
**Category:** PowerShell Help\
**Created:** [February 11, 2020, 8:16am UTC](https://forums.powershell.org/t/pass-parameter-in-invoke-command/13790 "2020-02-11T08:16:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lopauli](https://avatars.discourse-cdn.com/v4/letter/l/ea5d25/32.png) [@lopauli](https://forums.powershell.org/u/lopauli)\
**Post date:** [February 11, 2020, 8:16am UTC](https://forums.powershell.org/t/pass-parameter-in-invoke-command/13790/1 "2020-02-11T08:16:44Z")

</div>

Hello, I want to pass a path string with a parameter $p1 in below invoke-command but unfortunately it’s not working. Any idea why?

```
$Java_Pfad= "C:\Program Files (x86)\Java\jre1.8.0_231"
$AppVName = Get-AppvClientPackage -PackageId ef1af223-8cc4-4622-a8c2-cd5af4308d05

Invoke-Command -ScriptBlock { param($p1)

Get-AppvClientPackage -PackageId ef1af223-8cc4-4622-a8c2-cd5af4308d05
Start-AppvVirtualProcess -AppvClientObject $AppVName cmd.exe {/k
REG ADD HKEY_CURRENT_USER\Software\FRS\FiRE\Defaults /v JREPath /t REG_SZ /d $p1 /f}

} -ArgumentList $Java_Pfad
```

---

<div class="post-metadata">

**Author:** ![rob-simmers](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/rob-simmers/32/1010_2.png) [@rob-simmers](https://forums.powershell.org/u/rob-simmers)\
**Post date:** [February 11, 2020, 9:01am UTC](https://forums.powershell.org/t/pass-parameter-in-invoke-command/13790/2 "2020-02-11T09:01:12Z")

</div>

It’s not the path that is the issue, it is that you are referencing a local variable $AppVName, so the AppvClientObject is NULL. The Get-AppcClientPackage in the scriptblock is not assigned to the variable $AppVName. You can also use the $Using scope modifier:

> **[about Remote Variables - PowerShell](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_remote_variables?view=powershell-7)**
>
> Explains how to use local and remote variables in remote commands.

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:30pm UTC](https://forums.powershell.org/t/pass-parameter-in-invoke-command/13790/3 "2024-05-16T20:30:41Z")

</div>


