Powershell 在PS脚本中找不到XML元素

Powershell 在PS脚本中找不到XML元素,powershell,xml-parsing,Powershell,Xml Parsing,我正在尝试使用此powershell脚本[https://gist.github.com/557222]为了分析我的VS解决方案参考,因为我有冲突,但我不知道在哪里 问题是它不起作用,因为出现以下错误: ForEach-Object : Property 'HintPath' cannot be found on this object. Make sure that it exists. At C:\bsi\Projects\Bsi.ManagementConsole\Branches\Tan

我正在尝试使用此powershell脚本[https://gist.github.com/557222]为了分析我的VS解决方案参考,因为我有冲突,但我不知道在哪里

问题是它不起作用,因为出现以下错误:

ForEach-Object : Property 'HintPath' cannot be found on this object. Make sure that it exists.
At C:\bsi\Projects\Bsi.ManagementConsole\Branches\Tango58\Get-VSSolutionReferences.ps1:37 char:31
+                 ForEach-Object <<<<  {
    + CategoryInfo          : InvalidOperation: (.:OperatorToken) [ForEach-Object], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFoundStrict,Microsoft.PowerShell.Commands.ForEachObjectCommand
ForEach对象:在此对象上找不到属性“HintPath”。确保它存在。
在C:\bsi\Projects\bsi.ManagementConsole\Branchs\Tango58\Get-VSSolutionReferences.ps1:37 char:31

+ForEach Object注释掉行
Set StrictMode-Version Latest
,因为当您尝试访问对象上的属性
HintPath
时,该行会导致错误,并且该属性不存在。或者您可以将
$\ HintPath
上的检查修改为:

if (($_.psobject.Properties.Match('HintPath')) -ne $null -and $_.HintPath) {
    $RefPath = $ProjectRoot | Join-Path -ChildPath $_.HintPath
}
但根据我的简单测试,您需要在脚本的其他部分也执行此操作,例如,
找不到SpecificVersion