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