Here is the simple PowerShell Code that pulls the information of hotfix on multiple computers.
We need to create a text file for remote computers list that we are going to query the port status, here I have created a text file named as allservers.txt and saved it in location C\temp\allservers.txt
$ErrorActionPreference = "silentlycontinue "
$Allservers = Get-Content -Path "C:\temp\AllServers.txt"
foreach ($server in $Allservers)
{
$hotfix = $null
$hotfix = New-Object -TypeName psobject
$hotfix = Get-HotFix KB5004945 -ComputerName $server | Select-Object -Property PSComputerName, HotFixID,InstalledBy,InstalledOn
$hotfix | Add-Member -MemberType NoteProperty -Name PSComputerName -Value $hotfix.PSComputerName
$hotfix | Add-Member -MemberType NoteProperty -Name HotFixID -Value $hotfix.HotFixID
$hotfix | Add-Member -MemberType NoteProperty -Name InstalledBy -Value $hotfix.InstalledBy
$hotfix | Add-Member -MemberType NoteProperty -Name InstalledOn -Value $hotfix.InstalledOn
if ($hotfix.PSComputerName -eq $null)
{
$hotfix | Add-Member -MemberType NoteProperty -Name PSComputerName -Value $server -Force
$hotfix | Add-Member -MemberType NoteProperty -Name HotFixID -Value "HotFix Not Installed" -Force
$hotfix | Add-Member -MemberType NoteProperty -Name InstalledBy -Value N/A -Force
$hotfix | Add-Member -MemberType NoteProperty -Name InstalledOn -Value N/A -Force
}
$hotfix | Export-Csv -Path "C:\temp\Hotfixresult.csv" -Force -Append -NoTypeInformation
}
Leave a Reply Cancel reply