{"id":65,"date":"2017-09-07T07:32:36","date_gmt":"2017-09-07T07:32:36","guid":{"rendered":"http:\/\/michaelschultz.net\/tech\/?p=65"},"modified":"2018-05-23T00:20:22","modified_gmt":"2018-05-23T00:20:22","slug":"powershell-script-to-look-for-installed-kb","status":"publish","type":"post","link":"https:\/\/michaelschultz.net\/tech\/powershell-script-to-look-for-installed-kb\/","title":{"rendered":"PowerShell Script to Look for Installed KB"},"content":{"rendered":"<p>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.<!--more--><\/p>\n<div class=\"codecolorer-container powershell default\" style=\"overflow:auto;white-space:nowrap;width:500px;\"><div class=\"powershell codecolorer\"><span class=\"co1\">#set KB using kb followed by the KB number<\/span><br \/>\n<span class=\"re0\">$KBfind<\/span> <span class=\"sy0\">=<\/span> <span class=\"st0\">&quot;KB3150513&quot;<\/span><br \/>\n<br \/>\n<span class=\"re0\">$hotfix1<\/span> <span class=\"sy0\">=<\/span> Get<span class=\"sy0\">-<\/span>HotFix <span class=\"sy0\">|<\/span> <span class=\"kw2\">select<\/span> <span class=\"kw5\">-ExpandProperty<\/span> HotFixID<br \/>\n<br \/>\n<span class=\"co1\">#This example determines compliance in KB is installed, but can be altered to meet other purposes<\/span><br \/>\n<span class=\"kw3\">if<\/span> <span class=\"br0\">&#40;<\/span><span class=\"re0\">$hotfix1<\/span> <span class=\"kw4\">-eq<\/span> <span class=\"re0\">$KBfind<\/span><span class=\"br0\">&#41;<\/span><br \/>\n<span class=\"br0\">&#123;<\/span><br \/>\n<span class=\"re0\">$compliance<\/span> <span class=\"sy0\">=<\/span> <span class=\"st0\">&quot;true&quot;<\/span><br \/>\n<span class=\"br0\">&#125;<\/span><br \/>\n<span class=\"kw3\">else<\/span><br \/>\n<span class=\"br0\">&#123;<\/span><br \/>\n<span class=\"re0\">$compliance<\/span> <span class=\"sy0\">=<\/span> <span class=\"st0\">&quot;false&quot;<\/span><br \/>\n<span class=\"br0\">&#125;<\/span><br \/>\n$compliance<\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>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 &hellip; <a href=\"https:\/\/michaelschultz.net\/tech\/powershell-script-to-look-for-installed-kb\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;PowerShell Script to Look for Installed KB&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[5,4,14,13],"tags":[],"class_list":["post-65","post","type-post","status-publish","format-standard","hentry","category-dcm","category-configmgr","category-powershell","category-scripting"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p98a2r-13","post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/michaelschultz.net\/tech\/wp-json\/wp\/v2\/posts\/65","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/michaelschultz.net\/tech\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/michaelschultz.net\/tech\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/michaelschultz.net\/tech\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/michaelschultz.net\/tech\/wp-json\/wp\/v2\/comments?post=65"}],"version-history":[{"count":2,"href":"https:\/\/michaelschultz.net\/tech\/wp-json\/wp\/v2\/posts\/65\/revisions"}],"predecessor-version":[{"id":98,"href":"https:\/\/michaelschultz.net\/tech\/wp-json\/wp\/v2\/posts\/65\/revisions\/98"}],"wp:attachment":[{"href":"https:\/\/michaelschultz.net\/tech\/wp-json\/wp\/v2\/media?parent=65"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/michaelschultz.net\/tech\/wp-json\/wp\/v2\/categories?post=65"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/michaelschultz.net\/tech\/wp-json\/wp\/v2\/tags?post=65"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}