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

http://powershell.com/cs/forums/p/6860/11235.aspx#11235

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

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

and

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

0 Comments

Leave a Reply