You can run this script from the platforms that are selected. You can also query a Windows 2000 computer as a target, but it will not run the script. When running the script, you will need to make sure you provide it with the hotfix numbers, and provide computers that are on your network, and that you have rights to query. By default, WMI requires you to have local admin rights on the targeted computer when using remote WMI.


# ------------------------------------------------------------------------
# NAME: GetHotFixReport.ps1
# AUTHOR: ed wilson, Microsoft
# DATE: 8/25/2009
# KEYWORDS: WMI, Win32_QuickFixEngineering,
# PSObject, New-Object, Add-Member, Get-Content,
# Get-WmiObject, array
# COMMENTS: This takes two arguments. Both of 
# which can be supplied from the command line, hardcoded,
# or supplied via text file. To call the script from Windows PowerShell
# console: GetHotFixReport.ps1 -hotfix kb973815, kb952286 -computer berlin, lisbon
# OR to log to file:
# GetHotFixReport.ps1 -hotfix KB952286 -computer loopback  -log -file "C:\fso\hfix.txt
# ------------------------------------------------------------------------
  [String[]]$hotFix = @("KB973815", "KB952286"),
  [string[]]$computer = (get-content -path c:\fso\servers.txt),
  [string]$filepath = "C:\fso\hotfx.txt",
) #end Param

Function Get-HotFixStatus([string]$hotFix, [string]$computer)
  Get-WmiObject -class  win32_QuickFixEngineering `
  -Filter "HotFixID = '$hotfix'" -computername $computer
} #end function Get-HotFixStatus

Function Get-HotFixReport([string[]]$hotFix, [string[]]$computer)
  foreach($c in $computer)
    foreach ($h in $hotfix)
     $status =  $(if(Get-HotFixStatus -hotfix $h -computer $c) {$true} else {$false})
     $object = New-Object -TypeName PSObject
     $object | Add-Member -MemberType NoteProperty -Name Computer `
                     -Value $c
     $object | Add-Member -MemberType NoteProperty  -Name HotFix `
                     -Value $h
     $object | Add-Member -MemberType NoteProperty -Name Installed `
                     -Value $status
    } #end foreach hotfix
   } #end foreach computer
} #end function Get-FixReport

Function Out-HotFixLog ([string]$filepath)
 "Hot Fix Report $(Get-Date)" | Out-File -filepath $filepath -append
 Get-HotFixReport -hotfix $hotfix -computer $computer | 
 Sort-object -property hotfix | 
 Out-File -filepath $filepath -append
} #end function Out-HotFixLog

# *** Entry Point to Script ***

"Hot Fix Report $(Get-Date)"
Get-HotFixReport -hotfix $hotfix -computer $computer | 
Sort-object -property computer | 
Format-Table -Property * -autosize

# write to text file
if($logToFile) { Out-HotFixLog -filepath $filepath }