Question: Running Powershell script remotely with custom parameters

Hello Guys/Girls, I am trying to run this script remotely from a Windows 2008 R2

SCRIPT_NAME: runJMXClient.ps1

OS : Windows (PowerShell version)

DESC : Websphere JMX Client

This script get MBean metric from WebSphere using JMX, the metric to query

are read from the configuration file, see

Variable WASADM_HOME must be defined in environment

The configuration file must be exist in $WASADM_HOME\etc

Example of usage:


DATE : $Date$


AUTHOR : $Author$


NOTE : See also

For Linux/Unix use the wrapper script


$JAVA_HOME= “$Env:WASADM_HOME/bin/java/win”

$C1 = “$WASADM_HOME/lib/8.0.0/runtimes”
$C2 = “$WASADM_HOME/lib”



$L="-J-Dsun.rmi.level=FINEST -J-Djava.util.logging.config.file=$WASADM_HOME/etc/"

$_file = $args
$cmd = “$JAVA_HOME/bin/java.exe -cp “”$CLASSPATH”" JMXClient $WASADM_HOME/etc/$f 2> $WASADM_HOME/log/runJMXClient.err"

Invoke-Expression $cmd -ErrorAction SilentlyContinue

As you can see I have the -F parameter but when I try to run it: Invoke-Command -ComputerName mycompname -FilePath \mycompnameD$\Appls\IBM\was\scripts\runJMXClient.ps1 -f value it doesn’t work.

Do you know how can I run the script remotely and pass the value I need?

Look at the -Argument parameter of Invoke-Command. There’s a defined mechanism to do what you’re after.