我正在寻找一个脚本,该脚本将提示您,或者您可以在命令行中输入您需要在计算机上找到的知识库文章。到目前为止,我有以下内容,它会提示您输入KB,然后输入它,如果它找到了,它会返回是或否。在一次测试中,我输入了KB123456,并制作了其他Kb,它说它找到了,钻头搁浅。我是不是错过了什么?
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!"
}
尝试
if ($hotfix)
{
Write-Host $strComputer "has $id installed!"
}
Else {
write-host $strComputer "does not have $ID installed."
}