我正在使用一个脚本提示您,或者您可以在命令行中输入您需要在计算机上找到的知识库文章。到目前为止,我有以下内容,它将提示您输入KB并输入它,如果找到它,它会返回是或否。 对于测试我输入KB123456并组成其他Kb并且它说它发现它,有点stranage。我错过了什么吗?
Clear-Host
$strComputer = $env:computername #Sets the local computer name
$Id = Read-host 'What is the Hotfix ID?' #Prompts for KB article
$Hotfix = Get-HotFix -Id $Id -ErrorAction SilentlyContinue
if ($hotfix)
{
write-host $strComputer "does not have $ID installed."
}
Else {
Write-Host $strComputer "has $id installed!"
}
答案 0 :(得分:0)
尝试
if ($hotfix)
{
Write-Host $strComputer "has $id installed!"
}
Else {
write-host $strComputer "does not have $ID installed."
}