0
$commonElementsLocation = ((Get-Location).Path + "\FolderMatchingCommonWords.txt")
if ($commonElementsLocation) {
$result += Start-Job -InitializationScript {
$commonElements = Get-Content -Path $commonElementsLocation
} -ScriptBlock $testScriptBlock -ArgumentList "testing" | Wait-Job | Receive-Job
}
不知道我在做什麼錯在這裏 - 可能是一個愚蠢的錯誤,但我把周圍的啓動工作語句的條件,和PowerShell還提供了以下錯誤:PowerShell中獲取內容的路徑無效錯誤
Get-Content : Cannot bind argument to parameter 'Path' because it is null.
At line:1 char:39
+ $commonElements = (Get-Content -Path $commonElementsLocation)
+ ~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Get-Content], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.GetContentC
ommand
Running startup script threw an error: Cannot bind argument to parameter 'Path' because it is null..
+ CategoryInfo : OpenError: (localhost:String) [], RemoteException
+ FullyQualifiedErrorId : PSSessionStateBroken
正確。作業在完全獨立的PowerShell進程中運行。無論init腳本使用什麼「外部」變量,都應該使用'$ using:'引用它們,以便它們序列化到運行作業的PowerShell會話。 –
2014-09-13 21:55:49