Ying Li at myITforum.com

PowerShell & System Center

PowerShell script to check if a particular patch installed

$erroractionpreference = "SilentlyContinue"

$a = New-Object -comobject Excel.Application
$a.visible = $True

$b = $a.Workbooks.Add()
$c = $b.Worksheets.Item(1)

$c.Cells.Item(1,1) = "Machine Name"
$c.Cells.Item(1,2) = "PatchStatus"
$c.Cells.Item(1,3) = "Report Time Stamp"

$d = $c.UsedRange
$d.Interior.ColorIndex = 19
$d.Font.ColorIndex = 11
$d.Font.Bold = $True

$intRow = 2

Foreach ($strComputer in get-content C:\MachineList.Txt)
{
$c.Cells.Item($intRow,1)  = $strComputer

$PatchStatus = Get-WMIObject Win32_QuickFixEngineering -computer $strcomputer |where {$_.HotFixID -eq "KB925902"}
If($PatchStatus -eq $Null)
{
$c.Cells.Item($intRow,2).Interior.ColorIndex = 3
$c.Cells.Item($intRow,2) = "NO"
}
Else
{
$c.Cells.Item($intRow,2).Interior.ColorIndex = 4
$c.Cells.Item($intRow,2) = "YES"
}
$c.Cells.Item($intRow,3) = Get-Date
$intRow = $intRow + 1
}

$d.EntireColumn.AutoFit()
cls

 

Posted: May 03 2007, 09:43 AM by yli628 | with no comments
Filed under:

Comments

No Comments