I have been using the invoke-command quite a bit lately to do some remote installs and other things, and I ran into an issue passing parameters to the script to be run on the remote machine.

$script= { cmd /c “$pathRunInstall.bat” }

I quickly realized that the $path parameter was not getting passed the way I wanted it to be passed to the remote computer.  After a while of trying different syntax I decided to ask for help from the forums of powershell.com


Anyway long story short… it’s actually really simple to get around this little issue.

$script={param($path); cmd /c “$pathRunInstall.bat” }


invoke-command -computername $name -script $script -arguementlist $path

After those two super simple additions to my script I was on my way again, and learned a cool new trick in the process.

Categories: Powershell


Leave a Reply