powershell中的故障排除

powershell中的故障排除,powershell,scripting,Powershell,Scripting,我的行为非常奇怪。 我有一个If,elseif,else。 如果行得通,否则如果行得通,否则就永远不会发生 可能是什么 以下是脚本: $result = Get-AMTHardwareAsset $Computer -credential $VProCredential -textoutput if ($result.Contains("Unauthorized") -eq $true) { Add-Results "$Computer`tHardwareAssets-U

我的行为非常奇怪。 我有一个If,elseif,else。 如果行得通,否则如果行得通,否则就永远不会发生

可能是什么

以下是脚本:

$result = Get-AMTHardwareAsset $Computer -credential $VProCredential -textoutput
if ($result.Contains("Unauthorized") -eq $true)
    {
        Add-Results "$Computer`tHardwareAssets-Unauthorized"
    }
elseif ($result.Contains("Could not connect") -eq $true)
    {
        Add-Results "$Computer`tHardwareAssets-CannotConect"
    }

    else
    {
        Add-Results "TESTING"
    }

将脚本更改为硬编码
$result
为“Fubar”,并将
写入主机
替换为
添加结果

$result = 'Fubar'; #Get-AMTHardwareAsset $Computer -credential $VProCredential -textoutput
if ($result.Contains("Unauthorized") -eq $true)
{
    #Add-Results "$Computer`tHardwareAssets-Unauthorized"
    Write-Host "$Computer`tHardwareAssets-Unauthorized"
}
elseif ($result.Contains("Could not connect") -eq $true)
{
    #Add-Results "$Computer`tHardwareAssets-CannotConect"
    Write-Host "$Computer`tHardwareAssets-CannotConect"
}

else
{
    #Add-Results "TESTING"
    Write-Host "TESTING"
}
我得到了“TESTNG”


您没有包含的某些上下文适用,如果没有它,您将得到的唯一答案是:它看起来不错

哇。我不知道会是什么。我也在找我。我也测试了这个结果。“我如何解决这些问题?”李嘉图使用ISE的调试器。尤其是
$result
的值。