PowerShell Script to Look for Installed KB

This is a basic PowerShell script that can be used to determine if a KB related update is installed. You can use it to check and run an uninstall command or as part of a SCCM Compliance Settings configuration item. Yes, you can add updates directly to configuration baselines, but I am still learning PowerShell and wanted to do it the hard way. Plus, you can add additional script to it look at other things besides the presence of a KB to include installed software, state of a service, or registry settings. The compliance can also be switched around where having the KB installed is not complaint and then a remediation script can be used to uninstall the KB.

#set KB using kb followed by the KB number
$KBfind = "KB3150513"

$hotfix1 = Get-HotFix | select -ExpandProperty HotFixID

#This example determines compliance in KB is installed, but can be altered to meet other purposes
if ($hotfix1 -eq $KBfind)
{
$compliance = "true"
}
else
{
$compliance = "false"
}
$compliance