From e49c59da8a46d4be54f5fbb966833da957c08e84 Mon Sep 17 00:00:00 2001 From: Yorick Date: Wed, 20 Jan 2016 15:17:30 +0100 Subject: [PATCH] Syntax error :/ --- remove-kb.ps1 | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/remove-kb.ps1 b/remove-kb.ps1 index a39542a..e1de6de 100755 --- a/remove-kb.ps1 +++ b/remove-kb.ps1 @@ -23,19 +23,20 @@ function hide_update() { $searcher.Online = $false $criteria = "IsInstalled = 0" $result = $searcher.Search($criteria) - #$result.Updates | Foreach { - While ((!$found) -and ($i -lt $result.Updates.Count)) { - if ($result.Updates.Item($i).KBArticleIDs -match $kb) { - $found = 1 - if (!$result.Updates.Item($i).IsHidden) { - $result.Updates.Item($i).IsHidden = "True" - Write-Host -ForegroundColor green "Hidden" - } - else { + Foreach ($update in $result.Updates) { + $found = 0 + $kb | Foreach { + if ($update.KBArticleIDs -match $_) { + if (!$updates.Item($i).IsHidden) { + $update($i).IsHidden = "True" + Write-Host -ForegroundColor green "Hidden" + $found = 1 + } + else { Write-Host -ForegroundColor Yellow "Already hidden" + } } } - $i++ } if (!$found){ Write-Host -ForegroundColor Red "Not found"} } @@ -43,7 +44,7 @@ function hide_update() { Foreach($kbID in $kbIDs){ $kbNum = $kbID.Replace("KB","") Write-Host -NoNewline -ForegroundColor white "Uninstalling $kbID : " - if (Get-HotFix -Id $kbID -ErrorAction SilentlyContinue)){ + if (Get-HotFix -Id $kbID -ErrorAction SilentlyContinue){ Write-Host -NoNewline -ForegroundColor DarkGreen "found! " Write-Host -Nonewline -ForegroundColor white "removing ... " wusa.exe /uninstall /KB:$kbNum /norestart /quiet /log:wsua.log