powercli - Powershell.exe with many parameters (in Batch) - Error Ampersand not allowed -


i have batch file, calls powercli:

powershell –noexit -command "&{add-pssnapin vmware.vimautomation.core; $host.ui.rawui.windowtitle='powercli'}" 

but want add more stuff on command line, make junction command have:

powershell.exe -command "& c:\scripts\cluster.ps1 -vimhost %1 -vimuser %2 -vimpass %3" %4 

i tried put parameters in single line powershell did not work:

c:\> powershell -version 2.0 –noexit -command "&{add-pssnapin vmware.vimautomation.core; $host.ui.rawui.windowtitle='powercli'}" .\scripts\cluster_v1.ps1 -vimhost %1 -vimuser %2 -vimpass %3" %4 

ampersand not allowed. & operator reserved future use; use "&" pass ampersand string. + categoryinfo : parsererror: (:) [], parentcontainserrorrecordexception + fullyqualifiederrorid : ampersandnotallowed

how can concatenate various parameters in powershell command?

+1 "put commands in script , run script using -file."

but got curious , mocked small batch example worked okay on ps v3. in case helps track down problem, have 3 files in 1 directory:

"psscriptfile.ps1" contents:

param([string]$file,[string]$echome) gci $file | select length | ft -auto $echome 

"so.bat" contents:

powershell -noexit -command "&{add-pssnapin vmware.vimautomation.core; $host.ui.rawui.windowtitle='powercli';.\psscriptfile.ps1 -file somefile.lala 'maybe quotes gotcha?'}" 

and "somefile.lala" contents irrelevant. if can recreate problem in example on that scale, we're more help.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -