0
我試圖將文件名作爲參數傳遞給PowerShell。當我用測試路徑檢查條件時,它會拋出異常。Powershell測試路徑拋出錯誤
if (Test-path -path $argv[0]) {
&"$MsbuildBinPath\Msbuild.exe" $MSBuildFile "/t:BuildAll" "$Logger" "$ErrorLogger" "/p:AllComponents=$argv[0]"
if ($LastExitCode -ne 0) {
Write-Host "It failed, send a mail"
}
我想這樣稱呼它遵循
U:\Scripts>Powershell -file "U:\Scripts\Build.ps1" List.txt
它拋出異常如下
Cannot index into a null array.
At U:\Scripts\Build.ps1:37 char:29
+ if (Test-path -path $argv[ <<<< 0] -IsValid) {
+ CategoryInfo : InvalidOperation: (0:Int32) [], RuntimeException
+ FullyQualifiedErrorId : NullArray
哦..它是一個多麼愚蠢的錯誤 – Samselvaprabu 2011-12-26 14:10:00