diff --git a/remove-kb.ps1 b/remove-kb.ps1 index b23c229..9332799 100755 --- a/remove-kb.ps1 +++ b/remove-kb.ps1 @@ -43,19 +43,19 @@ function hide_update() { Foreach($kbID in $kbIDs){ $kbNum = $kbID.Replace("KB","") Write-Host -NoNewline -ForegroundColor white "Uninstalling $kbID : " - - if ($exist){ - Write-Host -NoNewline -ForegroundColor DarkGreen "found!" -ForegroundColor white "removing ... " + 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 - Do - { - Start-Sleep -Seconds 3 + Do + { + Start-Sleep -Seconds 3 }while(Invoke-Command -ScriptBlock {Get-Process | Where-Object {$_.name -eq "wusa"}}) - if(Get-HotFix -Id $kbID -ErrorAction SilentlyContinue){ - Write-Host -NoNewline -ForegroundColor Red "Failed" - } - else{ - Write-Host -NoNewline -ForegroundColor Green "Done" + if(Get-HotFix -Id $kbID -ErrorAction SilentlyContinue){ + Write-Host -NoNewline -ForegroundColor Red "Failed" + } + else{ + Write-Host -NoNewline -ForegroundColor Green "Done" } } else {