I have a script that will read server names in from a text file and then search for a specific KB update filename which works fine.
But what if I want to have each server searched in the serverlist.txt
file searched for multiple KB update files? How could I do that?
$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);
}
}