Powershell:FCIV脚本错误:“找不到路径,因为它不存在”

时间:2014-07-04 10:33:30

标签: powershell fciv

我是PowerShell的新手,所以我可能错过了一些简单的东西。我正在尝试为Start-PsFCIVoutlined here运行文件校验和。

我的尝试如下,我还尝试排除-Path参数,以及使用相对/绝对路径。

PS C:\Users\Lucas\Downloads> Start-PsFCIV -Path C:\Users\Lucas\Downloads\DXSDK_Jun10.exe -HashAlgorithm SHA1
Set-Location : Cannot find path 'C:\Users\Lucas\Downloads\DXSDK_Jun10.exe' because it does not exist.
At C:\Scripts\PsFCIV_2.5.ps1:227 char:3
+         Set-Location -LiteralPath $path
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\Users\Lucas\Downloads\DXSDK_Jun10.exe:String) [Set-Location], ItemNotFoundException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.SetLocationCommand

Test-Path : Cannot bind argument to parameter 'LiteralPath' because it is an empty string.
At C:\Scripts\PsFCIV_2.5.ps1:280 char:32
+         if (!(Test-Path -LiteralPath $XML)) {return New-Object PsFCIV.FCIV}
+                                      ~~~~
    + CategoryInfo          : InvalidData: (:) [Test-Path], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyStringNotAllowed,Microsoft.PowerShell.Commands.TestPathCommand

__fromxml : Input XML file is not valid FCIV XML file.
At C:\Scripts\PsFCIV_2.5.ps1:511 char:9
+     $sum = __fromxml $xml
+            ~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,__fromxml

Exception setting "VerboseForegroundColor": "Cannot convert value "-1" to type "System.Windows.Media.Color". Error: "Invalid cast from 'System.ConsoleColor' to 'System.Windows.Media.Color'.""
At C:\Scripts\PsFCIV_2.5.ps1:607 char:4
+             $host.PrivateData.VerboseForegroundColor = $Host.UI.RawUI.ForegroundColor
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], SetValueInvocationException
    + FullyQualifiedErrorId : ExceptionWhenSetting

You cannot call a method on a null-valued expression.
At C:\Scripts\PsFCIV_2.5.ps1:612 char:4
+             $sum.FILE_ENTRY.Add($entry)
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

Exception setting "VerboseForegroundColor": "Cannot convert value "-1" to type "System.Windows.Media.Color". Error: "Invalid cast from 'System.ConsoleColor' to 'System.Windows.Media.Color'.""
At C:\Scripts\PsFCIV_2.5.ps1:607 char:4
+             $host.PrivateData.VerboseForegroundColor = $Host.UI.RawUI.ForegroundColor
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], SetValueInvocationException
    + FullyQualifiedErrorId : ExceptionWhenSetting

如何让此命令生效?在搜索约15分钟后,我找不到任何解决方案或类似问题。

1 个答案:

答案 0 :(得分:0)

您获得的第一个异常是由Set-Location cmdlet抛出的,由于某种原因,它在Start-PsFCIV脚本中使用。 Set-Location期望一个文件夹作为其-LiteralPath参数,但是您将其传递给文件。

根据"Useful Examples" on the PsFCIV webpage,解决方案是使用-Include参数。例如:

Start-PsFCIV -Path C:\tmp -Include InstallPackage.msi -XML DB.XML -HashAlgorithm SHA512
# Checks only InstallPackage.msi file in C:\tmp folder by using SHA512 hash algorithm.