test1.ps1에서 powershell 파일 test.ps1을 실행해야합니다. PowerShell의 start-job 기능을 사용하고 있습니다.scriptblock 및 argumentlist를 사용하여 powershell 작업을 시작하는 중 오류가 발생했습니다.
:The expression after '&' in a pipeline element produced an object that was not valid. It must result in a command name, a script block, or a CommandInfo object.
param([string]fName, [string]lName]
나는 다음과 같은 오류가 계속 내 test1.ps1, 나는 내 test.ps1에서
$pathToFile = (Join-Path -Path $PSSCriptRoot -ChildPath "test.ps1")
$ar = $a, $b # all these variables have values assigned
Start-Job -Name job2 -ScriptBlock{& $pathToFile -fName $args[0] -lName $args[1]} -ArgumentList $ar
을 가지고, 내가 좋아하는 매개 변수로 FNAME 및 LNAME이
문제가 여기에 있습니다 Start-Job -Name job2 -ScriptBlock{& $pathToFile -fName $args[0] -lName $args[1]} -ArgumentList $ar
하지만이 문제를 해결할 해결책을 찾지 못한 것 같습니다. 그리고 예, $ pathToFile에 test.ps1 => C : \ foo \ test.ps1의 정확한 경로가 포함되어 있는지 확인했습니다. 도움이나 제안을 해주셔서 감사합니다.
이것은 작업 컨텍스트에서 실행할 때 정의되지 않은 로컬 변수로 귀결되는 OP 질문과 관련이 거의 없습니다. – mklement0