# Set the current directory variable to the script root
$currentDirectory=$PSScriptRoot
# Load the content of the two text files
$hotfixes=Get-Content $currentDirectory\hotfixes.txt
$computers=Get-Content $currentDirectory\computers.txt
# For each hotfix in the file hotfixes.txt
foreach($hotfix in $hotfixes){
# Write to console and then to output.txt
Write-Host "$hotfix" -foregroundcolor Yellow
Add-Content $currentDirectory\output.txt "$hotfix`n"
Write-Host "----------------------------------------------------" -foregroundcolor Magenta
Add-Content $currentDirectory\output.txt "----------------------------------------------------`n"
#For each computer in computers.txt
foreach($computer in $computers) {
# If the hotfix is found on the computer
if (Get-WmiObject -Computer $computer -Class Win32_QuickFixEngineering -Filter "HotFixID='$hotfix'" -erroraction silentlycontinue)
{
Write-Host "$computer has $hotfix installed" -foregroundcolor green
Add-Content $currentDirectory\output.txt "$computer has $hotfix installed`n"
}
else
{
Write-Host "$computer does not have $hotfix installed (or failed to connect)" -foregroundcolor Red
Add-Content $currentDirectory\output.txt "$computer does not have $hotfix installed (or failed to connect)`n"
}
}
Write-Host "----------------------------------------------------" -foregroundcolor Magenta
Add-Content $currentDirectory\output.txt "----------------------------------------------------`n"
Write-Host ""
Add-Content $currentDirectory\output.txt "`n"
}