我有一个脚本,它将从文本文件中读取服务器名称,然后搜索可以正常工作的特定 KB 更新文件名。
但是,如果我想让每个服务器在serverlist.txt
文件中搜索多个 KB 更新文件,该怎么办?我怎么能那样做?
$CheckComputers = get-content c:\temp\Path\serverlist.txt
# Define Hotfix to check
$CheckHotFixKB = "KB1234567";
foreach($CheckComputer in $CheckComputers)
{
$HotFixQuery = Get-HotFix -ComputerName $CheckComputer | Where-Object {$_.HotFixId -eq $CheckHotFixKB} | Select-Object -First 1;
if($HotFixQuery -eq $null)
{
Write-Host "Hotfix $CheckHotFixKB is not installed on $CheckComputer";
}
else
{
Write-Host "Hotfix $CheckHotFixKB was installed on $CheckComputer on by " $($HotFixQuery.InstalledBy);
}
}