문제

Would any of you possibly know why this is not working?

Start-Process $PSHOME\powershell.exe -ArgumentList "-NoExit -Command & `"{$outvar1 = 4+4; `"out: $outvar1`"}`"" -Wait

The ultimate purpose for this is so that i can run a script block as another user with the addition of the -Credential option. But i can not get this simple script block to work yet. Many thanks. Chris.

도움이 되었습니까?

해결책

Here is somthing that is working:

PS C:\> Start-Process $PSHOME\powershell.exe -ArgumentList "-NoExit","-Command  `"&{`$outvar1 = 4+4; `"write-output `$outvar1`"}`"" -Wait

-ArgumentList is an array of strinds $outvar is interpreted so I use `$outvar

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top