{"id":19451,"date":"2021-04-02T00:15:00","date_gmt":"2021-04-01T22:15:00","guid":{"rendered":"http:\/\/159.69.82.204\/win\/?p=19451"},"modified":"2021-04-01T12:20:03","modified_gmt":"2021-04-01T10:20:03","slug":"script-v2-zur-mrz-2021-update-bereinigung-bei-druckproblemen","status":"publish","type":"post","link":"https:\/\/borncity.com\/win\/2021\/04\/02\/script-v2-zur-mrz-2021-update-bereinigung-bei-druckproblemen\/","title":{"rendered":"Script V2 for March 2021 update cleanup to fix printing issues"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" title=\"Update\" style=\"border-left-width: 0px; border-right-width: 0px; border-bottom-width: 0px; float: left; margin: 0px 10px 0px 0px; display: inline; border-top-width: 0px\" border=\"0\" alt=\"Windows Update\" src=\"https:\/\/www.borncity.com\/blog\/wp-content\/uploads\/2015\/02\/Update.jpg\" width=\"54\" align=\"left\" height=\"54\">[<a href=\"https:\/\/www.borncity.com\/blog\/2021\/03\/31\/script-v2-zur-mrz-2021-update-bereinigung-bei-druckproblemen\/\" target=\"_blank\" rel=\"noopener\">German<\/a>]German blog reader <em>bon-go <\/em>sent me his revised PowerShell\/batch script to uninstall the buggy March 2021 updates in Windows 10 that are causing the printing issues reported here on the blog. I'm posting the updated version of the script here on the blog &#8211; perhaps it will be of interest to someone.<\/p>\n<p><!--more--><\/p>\n<h2>Background: March 2021 printing issues<\/h2>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" src=\"https:\/\/vg08.met.vgwort.de\/na\/d43b567eef264d0eaa3c8dcdce5ae0ce\" width=\"1\" height=\"1\">The Windows security updates from March 9, 2021, closed numerous vulnerabilities in the operating system. However, users reported significant printing issues shortly after installing the security updates (and Microsoft has confirmed these issues). <\/p>\n<ul>\n<li>There were the BlueScreens that occurred when printing on various printers (mostly Kyocera) (see <a href=\"https:\/\/borncity.com\/win\/2021\/03\/10\/windows-10-2004-20h2-update-kb5000802-verursacht-bsod-beim-drucken-in-win32kfull-sys-zurckgezogen\/\">Windows 10 Updates KB5000802\/KB5000808 causes BSOD when printing in win32kfull.sys \u2013 pulled?<\/a> ).\n<li>And there were still massive issues, after Microsoft issued a fix for the BlueScreen bug (see my blog post <a href=\"https:\/\/borncity.com\/win\/2021\/03\/17\/windows-10-weiterhin-probleme-mit-der-druckausgabe-mrz-2021\/\">Windows 10: Still printing issues after update installation (March 2021)<\/a>).<\/li>\n<\/ul>\n<p>What followed was an update orgy that made many things worse. Above all, the installation of the fix updates was always associated with the risk that something went wrong. In response to my German blog post <a href=\"https:\/\/www.borncity.com\/blog\/2021\/03\/23\/windows-7-8-1-server-korrektur-updates-fr-druckprobleme-mrz-2021\/\">Windows 7\/8.1\/Server: Korrektur-Updates f\u00fcr Druckprobleme (M\u00e4rz 2021)<\/a>, Andy offered in <a href=\"https:\/\/www.borncity.com\/blog\/2021\/03\/23\/windows-7-8-1-server-korrektur-updates-fr-druckprobleme-mrz-2021\/#comment-103618\">this comment<\/a> to provide his generic PowerShell script to clean up the system from the problematic updates for a general use. I've published the 1st version of the PowerShell script within the blog post <a href=\"https:\/\/borncity.com\/win\/2021\/03\/25\/powershell-script-to-uninstall-windows-updates-to-fix-march-2021-printing-issues\/\">PowerShell Script to uninstall Windows Updates, to fix March 2021 Printing issues<\/a>.  <\/p>\n<h2>Updated script\/batch<\/h2>\n<p>In <a href=\"https:\/\/www.borncity.com\/blog\/2021\/03\/25\/druckerprobleme-mrz-2021-powershell-script-zur-update-bereinigung\/#comment-103901\">this comment<\/a>, blog reader bon-go mentioned his new version of the script he has written, because there were issues on some Windows systems. He has send me the new script\/batch by mail with the notes below (thanks for sharing).<\/p>\n<blockquote>\n<p>the original script worked fine for us for the most part &#8211; but depending on the Windows version not everywhere and not silent. Attached is the updated version for this and similar problems. <\/p>\n<p>Note: this is a batch script which starts Powershell, so save as cmd.<\/p>\n<p>The script runs once and any problematic updates must be uninstalled once with 'OK' (wusa with the parameter quiet or dism does not work everywhere, it also tries to hide the update immediately, works rather rarely &#8211; only for minor updates).<\/p>\n<p>Then restart the PC as shown. <\/p>\n<p>After the PC restart run the script again, everything runs as before. If you now try to uninstall the same update again, it is an endless loop, a timing problem when uninstalling and installing.<\/p>\n<p>Normally the script finds the previously uninstalled problematic updates and hides them, this is also displayed.<\/p>\n<p>If the hiding is not executed (no yellow line \/ no display) then:<br \/>&#8211; the update was withdrawn<br \/>&#8211; the PC needs a little bit longer until it wants to find it again<br \/>(start the script again after 1-2 min.)<\/p>\n<p>Have fun &#8230;<\/p>\n<\/blockquote>\n<p>Sounds promising. I received the script as an e-mail &#8211; here is the version that can be copied to an editor via clipboard and then saved as a batch file (.cmd).<\/p>\n<pre>;@echo off &amp; setlocal &amp; set localfname=%~f0\n;Findstr -rbv ; %0 | powershell -c -\n;goto:BatchExit\n\n# removes the Windows updates from 03\/2021 which cause printer problems \n#   as of 03\/23\/2021 'around noon', see also \n#   *https:\/\/borncity.com\/win\/2021\/03\/22\/windows-10-mrz-2021-update-erneut-freigegeben\/<br>#\n# this batch + powershell script removes various updates based on the \n#   name \/ KB numbers and hides them permanently,  \n#   the script needs local administrator rights, it asks for them<br>#\n# if the script has run once and updates to be removed were found \n#   updates have been found, then be sure to restart the computer and <br>#   directly after the restart run the script again, only \n#   then the last updates to be removed will really be disappear. \n#\n# if also after repeated call again and again (the same)uninstalled,<br>#   then manually intervene, clean the local Windows Update Cache<br>#   (Script 02WindowsUpdatesL\u00f6schen.cmd),manually uninstall the updates\n#   (if possible)and hide the updates(with wushowhide.diagcab)\n#\n# various parts of the script are just mangled and have been copied <br>#   shamelessly copied from:<br>#   *https:\/\/www.powershellmagazine.com\/2014\/03\/19\/how-to-view-and-restore-hidden-windows-updates-with-powershell\/\n\n\n# the problematic updates \/ KB numbers (_without_ the 'KB' label) to be removed and hidden<br>$HotFixesToRemove=@(\"5000802\", \"5000808\", \"5000822\", \"5000809\", \"5000812\", \"5000803\", \"5000807\", \"5001567\", \"5001566\", \"5001568\", \"5001565\")\n\nFunction Main {\n    [Cmdletbinding()]\n    Param()\n    Process {\n        # test if the script was executed as administrator, if not then try restart with elevated privileges\n        CheckAndRaiseElevation\n        \n        # remove the problematic updates <br>        If( RemoveWrongHotfixes ) {\n<br><br><br>            Write-Host \"At least one Windows update was found which was uninstalled.\"\n            Write-Host \"Please wait, collecting information about pending updates...\"\n            HideWrongHotfixes\n            Write-Host \"The previously uninstalled Windows updates have been hidden as far as possible.\"\n            Write-Host \"Please restart the computer immediately and re-run the program\"\n            Write-Host \"right after the start again.\"\n            Write-Host \"n case of an infinite loop (if this has already been done several times and this\"\n            Write-Host \"message appears again and again then uninstall and hide manually.\"\n            waitkey \"Continue with any key, then restart manually [x]\" | Out-Null\n        } Else {\n            # none of the problematic updates could be uninstalled anymore, try to find them \n            # use the try-and-error method to hide them permanently\n            Write-Host \"None of the problematic updates is installed.\"\n            Write-Host \"Please wait, gather information about pending updates ...\"\n            HideWrongHotfixes\n            Write-Host \"The previously uninstalled Windows updates have been hidden as far as possible.\"\n            WaitKey \"The program can be terminated, continue with any key[x]\" | Out-Null\n        }\n    }\n}\n\n\nFunction WaitKey($___text){\n    Write-Host $___text\n    $___x = $host.UI.RawUI.ReadKey(\"NoEcho,IncludeKeyDown\") | Out-Null\n    Return $___x\n}\n\nFunction CheckAndRaiseElevation {\n    [Cmdletbinding()]\n    Param()\n    Process {\n        # Test for sufficient rights\n        $IsElevated=([System.Security.Principal.WindowsPrincipal][System.Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator)\n\n        If( -not $IsElevated ) {\n            Write-Host \"Not enough user rights, elevate rights.\"\n            Try {\n                # try to run the batch with admin rights\n                Start-Process -FilePath $env:localfname -Verb RunAs -ErrorAction SilentlyContinue\n            }\n            Catch {\n                Write-Host \"User refused to elevate rights - abort!\"\n                WaitKey \"Press any key[x]\" | Out-Null\n            }\n            Exit\n        }\n        # Write-Host \"Program runs with admin rights.\"\n        # change to the original program path if possible, also UNC and mapped network drives possible<br>        Set-Location $(Split-Path -Parent $env:localfname)\n    }\n}\n\n# removes if possible all problematic hotfixes specified as parameters <br>Function RemoveWrongHotfixes {\n    [Cmdletbinding()]\n    Param()\n    Process {\n        $ReturnVal=$False\n        $InstalledHotFixes=$(Get-WmiObject -Class win32_quickfixengineering).HotFixID\n        Write-Host \"Ueberpruefe alle installierten Updates\"\n        Foreach( $InstalledHotFix in $InstalledHotFixes ) {\n            Foreach($HotFixToRemove in $HotFixesToRemove) {\n                If( $InstalledHotFix -match \"$HotFixToRemove\") {\n                    Write-Host \"Das Update $InstalledHotFix wird entfernt\"            \n                    Start-Process -FilePath \"wusa.exe\" -Argumentlist \"\/Uninstall \/KB:$HotFixToRemove \/norestart\" -PassThru -Wait | Out-Null\n                    $ReturnVal=$true\n                }\n            }    \n        }\n        Return $ReturnVal\n    }\n}\n\n\n# hide, if possible, problematic Hotfixes \nFunction HideWrongHotfixes {\n    [Cmdletbinding()]\n    Param()\n    Process {\n        SearchForWindowsUpdates\n        $ActUpdates=Get-WindowsUpdate\n        Foreach( $ActUpdate in $ActUpdates ) {\n            Foreach($HotFixToRemove in $HotFixesToRemove) {\n                If( $ActUpdate.Title -match \"$HotFixToRemove\") {\n                    Write-Host \"Update $($ActUpdate.Title) removed\"            \n                    Set-WindowsHiddenUpdate $ActUpdate -Hide $True -Verbose\n                }\n            }    \n        }\n    }\n}    \n\nFunction Get-WindowsUpdate {\n    [Cmdletbinding()]\n    Param()\n    Process {\n        Try {\n            Write-Verbose \"Query all Windows Updates\"\n            $Session = New-Object -ComObject Microsoft.Update.Session\n            $Searcher = $Session.CreateUpdateSearcher()\n            $Criteria = \"IsInstalled=0 and DeploymentAction='Installation' or IsPresent=1 and DeploymentAction='Uninstallation' or IsInstalled=1 and DeploymentAction='Installation' and RebootRequired=1 or IsInstalled=0 and DeploymentAction='Uninstallation' and RebootRequired=1\"\n            $SearchResult = $Searcher.Search($Criteria)\n            $SearchResult.Updates\n        } Catch {\n            Write-Warning -Message \"Query Windows Updates failed with error $($_.Exception.Message)\"\n        }\n    }\n}\n\nFunction SearchForWindowsUpdates {\n    [Cmdletbinding()]\n    Param()\n    Process {\n        # Define update criteria\n        $Criteria = \"IsInstalled=0\"\n\n        # Search for relevant updates\n        $Searcher = New-Object -ComObject Microsoft.Update.Searcher\n        $SearchResult = $Searcher.Search($Criteria).Updates\n    }\n}    \n\nFunction SearchAndInstallWindowsUpdates {\n    [Cmdletbinding()]\n    Param()\n    Process {\n        # Define update criteria\n        $Criteria = \"IsInstalled=0\"\n\n        # Search for relevant updates\n        $Searcher = New-Object -ComObject Microsoft.Update.Searcher\n        $SearchResult = $Searcher.Search($Criteria).Updates\n\n        # Download updates\n        $Session = New-Object -ComObject Microsoft.Update.Session\n\n        $Downloader = $Session.CreateUpdateDownloader()\n        $Downloader.Updates = $SearchResult\n        $Downloader.Download()\n\n        $Installer = New-Object -ComObject Microsoft.Update.Installer\n        $Installer.Updates = $SearchResult\n        $Result = $Installer.Install()\n        If ($Result.rebootRequired) { \n#            shutdown.exe \/t 0 \/r \n        }\n    }\n}\n\nFunction Remove-WindowsUpdate {\n    [CmdletBinding()]  \n    param (  \n        [parameter(Mandatory=$True)] $RemoveKB\n    )\n\n    $Searcher = New-Object -ComObject Microsoft.Update.Searcher\n    $RemoveCollection = New-Object -ComObject Microsoft.Update.UpdateColl\n\n    # hole alle installierten Updates\n    $SearchResult = $Searcher.Search(\"IsInstalled=1\")\n\n    # erzeuge Liste der zu loeschenden Updates wenn installiert\n    $SearchResult.Updates | ? { $_.KBArticleIDs -in $RemoveKB } | % { $RemoveCollection.Add($_) }\n\n    # loesche ...\n    if ($RemoveCollection.Count -gt 0) {\n        $Installer = New-Object -ComObject Microsoft.Update.Installer\n        $Installer.Updates = $RemoveCollection\n        $Installer.Uninstall()\n    } else { \n        Write-Warning \"No matching Windows Updates found for:`n$($RemoveKB|Out-String)\" \n    }\n}\n\n# Bonus\nFunction Show-WindowsUpdate {\n    Get-WindowsUpdate |\n    Select Title,isHidden,\n        @{l='Size (MB)';e={'{0:N2}' -f ($_.MaxDownloadSize\/1MB)}},\n        @{l='Published';e={$_.LastDeploymentChangeTime}} |\n    Sort -Property Published\n}\n\n# \n# Show-WindowsUpdate \n# Show-WindowsUpdate | Where { $_.isHidden }| Out-GridView\n\nFunction Set-WindowsHiddenUpdate {\n    [Cmdletbinding()]\n    Param(\n        [Parameter(ValueFromPipeline=$true,Mandatory=$true)]\n        [System.__ComObject[]]$Update,\n        [Parameter(Mandatory=$true)]\n        [boolean]$Hide\n    )\n    Process {\n        $Update | ForEach-Object -Process {\n            if ((($_.pstypenames)[0] -eq 'System.__ComObject#{c1c2f21a-d2f4-4902-b5c6-8a081c19a890}') -or \n                (($_.pstypenames)[0] -eq 'System.__ComObject#{70cf5c82-8642-42bb-9dbc-0cfd263c6c4f}') -or \n                (($_.pstypenames)[0] -eq 'System.__ComObject#{918efd1e-b5d8-4c90-8540-aeb9bdc56f9d}')) {\n                try {\n                    $_.isHidden = $Hide\n                    Write-Verbose -Message \"Hide Update $($_.Title)\"\n                } catch {\n                    Write-Warning -Message \"Hiding Windows Update failed, error $($_.Exception.Message)\"\n                }\n            } else {\n                Write-Warning -Message \"Ignore passed object\"\n            }\n        }\n    }\n}\n\n# Examples: hide all still open Updates\n#   Get-WindowsUpdate | Set-WindowsHiddenUpdate -Hide:$true -Verbose\n# Beispiel: verstecke alle noch offenene Definitionsupdates\n#   Get-WindowsUpdate | Where { $_.Title -match 'Definitionsupdate' } | Set-WindowsHiddenUpdate -Hide:$false\n# Beispiel: verstecke alle noch offenene sicherheitsupdates\n#   Get-WindowsUpdate | Where { $_.Title -match 'Sicherheitsupdate' } | Set-WindowsHiddenUpdate -Hide:$false\n# Beispiel: verstecke Browser Choice Updates\n#   Get-WindowsUpdate | Where { $_.Title -match 'Microsoft Browser Choice Screen Update'} | Set-WindowsHiddenUpdate -Hide $true -Verbose\n\n\nmain\n\n\n;:BatchExit\n;REM Note: this end of the batch script is executed immediately, it does not wait for the end of the Powershell!\n;goto :eof\n\n# Date 22.03.2021\n#\n# The errors are \/ were probably finally fixed with the following updates on 18.03 or 22.03.2021\n# KB5001642 f\u00fcr Windows Server 2008 SP2 x64 (ESU)\n#       http:\/\/download.windowsupdate.com\/d\/msdownload\/update\/software\/updt\/2021\/03\/windows6.0-kb5001642-x64_4ae1b3c5cebedcd27fe50add6a34e70a00d19b76.msu\n# KB5001639 f\u00fcr Windows 7 SP1 x86  (ESU)\n#       http:\/\/download.windowsupdate.com\/d\/msdownload\/update\/software\/updt\/2021\/03\/windows6.1-kb5001639-x86_f7571200399e9c1099c37cc78c5b0a5481259989.msu\n# KB5001639 f\u00fcr Windows 7 SP1 x64  (ESU)\n#       http:\/\/download.windowsupdate.com\/d\/msdownload\/update\/software\/updt\/2021\/03\/windows6.1-kb5001639-x64_de64f5cb314e3eac59bb3c4371c9ba802adf0f22.msu\n# KB5001639 f\u00fcr Windows Server 2008 R2 (ESU)\n#       http:\/\/download.windowsupdate.com\/d\/msdownload\/update\/software\/updt\/2021\/03\/windows6.1-kb5001639-x64_de64f5cb314e3eac59bb3c4371c9ba802adf0f22.msu\n# KB5001641 f\u00fcr Windows Server 2012 x64\n#       http:\/\/download.windowsupdate.com\/d\/msdownload\/update\/software\/updt\/2021\/03\/windows8-rt-kb5001641-x64_ec0dc33ff8d0d0381eb3fe9595c8a96ccebf9e61.msu\n# KB5001640 f\u00fcr Windows 8.1 x86\n#       http:\/\/download.windowsupdate.com\/d\/msdownload\/update\/software\/updt\/2021\/03\/windows8.1-kb5001640-x86_149741dd2206faf42303dd7a6800567b681367be.msu\n# KB5001640 f\u00fcr Windows 8.1 x64\n#       http:\/\/download.windowsupdate.com\/d\/msdownload\/update\/software\/updt\/2021\/03\/windows8.1-kb5001640-x64_7aa82103f5e37a9d3c2ce2b608c903ed0855ac3b.msu\n# KB5001640 f\u00fcr Windows Server 2012 R2\n#       http:\/\/download.windowsupdate.com\/d\/msdownload\/update\/software\/updt\/2021\/03\/windows8.1-kb5001640-x64_7aa82103f5e37a9d3c2ce2b608c903ed0855ac3b.msu\n# KB5001631 f\u00fcr Windows 10 1507 und Server 2016\n# KB5001634 f\u00fcr Windows 10 1803 \n# KB5001638 f\u00fcr Windows 10 1809 und Server 2019\n# KB5001648 f\u00fcr Windows 10 1909\n# KB5001649 f\u00fcr Windows 10 2004 und 20H2\n# \n# fehlerhaft waren bisher die Updates KB5000802, KB5000808, KB5000822, KB5000809, KB5000812, KB5000803, KB5000807, KB5001567, KB5001566, KB5001568, KB5001565\n<\/pre>\n<p>The original German edition of the script may be <a href=\"https:\/\/www.borncity.com\/blog\/wp-content\/uploads\/2021\/03\/01WindowsUpdateProblem202103-deinstallieren-2.txt\" target=\"_blank\" rel=\"noopener\">downloaded here<\/a>. Have fun.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>[German]German blog reader bon-go sent me his revised PowerShell\/batch script to uninstall the buggy March 2021 updates in Windows 10 that are causing the printing issues reported here on the blog. I'm posting the updated version of the script here &hellip; <a href=\"https:\/\/borncity.com\/win\/2021\/04\/02\/script-v2-zur-mrz-2021-update-bereinigung-bei-druckproblemen\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[463,2],"tags":[399,195,76],"class_list":["post-19451","post","type-post","status-publish","format-standard","hentry","category-issue","category-windows","tag-fix","tag-update","tag-windows-10"],"_links":{"self":[{"href":"https:\/\/borncity.com\/win\/wp-json\/wp\/v2\/posts\/19451","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/borncity.com\/win\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/borncity.com\/win\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/borncity.com\/win\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/borncity.com\/win\/wp-json\/wp\/v2\/comments?post=19451"}],"version-history":[{"count":0,"href":"https:\/\/borncity.com\/win\/wp-json\/wp\/v2\/posts\/19451\/revisions"}],"wp:attachment":[{"href":"https:\/\/borncity.com\/win\/wp-json\/wp\/v2\/media?parent=19451"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/borncity.com\/win\/wp-json\/wp\/v2\/categories?post=19451"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/borncity.com\/win\/wp-json\/wp\/v2\/tags?post=19451"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}