;@echo off & setlocal & set localfname=%~f0 ;Findstr -rbv ; %0 | powershell -c - ;goto:BatchExit # entfernt die Windows Updates aus 03/2021 welche Druckerprobleme # verursachen, Stand 23.03.2021 'gegen Mittag', siehe auch # https://www.borncity.com/blog/2021/03/22/windows-10-mrz-2021-update-erneut-freigegeben/ # # dieses Batch + Powershell Skript entfernt diverse Updates anhand der # Bezeichnung / KB Nummern und blendet diese dauerhaft aus, # das Skript benoetigt lokale Administratorrechte, es fragt diese an # # wenn das Skript einmal durchgelaufen ist und dabei zu entfernende # Updates gefunden wurden, dann unbedingt den Computer neu starten und # direkt nach dem Neustart das Skript noch einmal laufen lassen, erst # dabei werden tlw. die letzten auszublendenen Updates wirklich # verschwinden # # wenn auch nach mehrmaligem Aufruf immer wieder (die gleichen) Updates # deinstalliert werden dann manuell eingreifen, den Windows Update # Cache lokal loeschen (Skript 02WindowsUpdatesLöschen.cmd), die # Updates manuell deinstallieren und (wenn ueberhaupt moeglich) # manuell ausblenden (mit wushowhide.diagcab) # # diverse Teile des Skriptes sind nur verschlimmbessert und wurden # schamlos kopiert von: # https://www.powershellmagazine.com/2014/03/19/how-to-view-and-restore-hidden-windows-updates-with-powershell/ # die problematischen Updates / KB Nummern (_ohne_ die Bezeichnung 'KB') die entfernt und ausgeblendet werden sollen $HotFixesToRemove=@("5000802", "5000808", "5000822", "5000809", "5000812", "5000803", "5000807", "5001567", "5001566", "5001568", "5001565") Function Main { [Cmdletbinding()] Param() Process { # teste ob das Skript als Administrator ausgefuehrt wurde, wenn nicht dann versuche Neustart mit erhoehten Rechten CheckAndRaiseElevation # entferne die problematischen Updates If( RemoveWrongHotfixes ) { Write-Host "Es wurde mind. ein Windows Update gefunden welches deinstalliert wurde." Write-Host "Bitte warten, sammle Informationen ueber noch ausstehende Updates ..." Get-WindowsUpdate | Where { $_.Title -match $HotFixesToRemove} | Set-WindowsHiddenUpdate -Hide $True -Verbose Write-Host "Die zuvor deinstallierten Windows Updates wurden soweit möglich ausgeblendet." Write-Host "Bitte umgehend den Computer neu starten und direkt nach dem Start das Programm" Write-Host "erneut ausfuehren." Write-Host "Im Fall einer Endlosschleife (falls dies schon mehrfach gemacht wurde und diese" Write-Host "Meldung immer wieder erscheint dann die Deinstallation und das Ausblenden" Write-Host "manuell durchfuehren." waitkey "Weiter mit beliebiger Taste, danach manuell neu starten [x]" | Out-Null } Else { # es konnte keines der problmatisches Updates mehr deinstalliert werden, versuche die zu finden # mit der try-and-error-methode dauerhaft auszublenden Write-Host "Bitte warten, sammle Informationen ueber noch ausstehende Updates ..." Get-WindowsUpdate | Where { $_.Title -match $HotFixesToRemove} | Set-WindowsHiddenUpdate -Hide $True -Verbose Write-Host "Die zuvor deinstallierten Windows Updates wurden soweit möglich ausgeblendet." WaitKey "Das Programm kann beendet werden, weiter mit beliebiger Taste [x]" | Out-Null } } } Function WaitKey($___text){ Write-Host $___text $___x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") | Out-Null Return $___x } Function CheckAndRaiseElevation { [Cmdletbinding()] Param() Process { # Test ob mit genug Rechten gestartet $IsElevated=([System.Security.Principal.WindowsPrincipal][System.Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator) If( -not $IsElevated ) { Write-Host "Das Programm hat zu wenig Rechte: erhoehe Rechte." Try { # versuche das Batch Skript erneut mit lokalen Administratorrechten zu starten Start-Process -FilePath $env:localfname -Verb RunAs -ErrorAction SilentlyContinue } Catch { Write-Host "Der Benutzer hat die Erhoehung der Rechte verweigert - Abbruch!" WaitKey "Ende mit beliebiger Taste [x]" | Out-Null } Exit } # Write-Host "Programm laeuft aktuell mit Administrator Rechten." # wechsle in den urspr. Programmpfad wenn geht, auch UNC und gemappte Netzlaufwerke moeglich Set-Location $(Split-Path -Parent $env:localfname) } } # entfernt wenn möglich alle als Parameter angegebenen problematischen Hotfixes Function RemoveWrongHotfixes { [Cmdletbinding()] Param() Process { $ReturnVal=$False $InstalledHotFixes=$(Get-WmiObject -Class win32_quickfixengineering).HotFixID Foreach( $InstalledHotFix in $InstalledHotFixes ) { Foreach($HotFixToRemove in $HotFixesToRemove) { If( $InstalledHotFix -match "$HotFixToRemove") { Write-Host "Das Update $InstalledHotFix wird entfernt" Start-Process -FilePath "wusa.exe" -Argumentlist "/Uninstall /KB:$HotFixToRemove /quiet /norestart" Write-Host "Das Update $InstalledHotFix wird dauerhaft ausgeblendet" Get-WindowsUpdate | Where { $_.Title -match "$HotFixToRemove"} | Set-WindowsHiddenUpdate -Hide $true -Verbose $ReturnVal=$true } } } Return $ReturnVal } } Function Get-WindowsUpdate { [Cmdletbinding()] Param() Process { Try { Write-Verbose "Abfrage aller Windows Updates" $Session = New-Object -ComObject Microsoft.Update.Session $Searcher = $Session.CreateUpdateSearcher() $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" $SearchResult = $Searcher.Search($Criteria) $SearchResult.Updates } Catch { Write-Warning -Message "Abfrage der Windows Updates fehlgeschlagen, Fehler $($_.Exception.Message)" } } } # Bonus Function Show-WindowsUpdate { Get-WindowsUpdate | Select Title,isHidden, @{l='Size (MB)';e={'{0:N2}' -f ($_.MaxDownloadSize/1MB)}}, @{l='Published';e={$_.LastDeploymentChangeTime}} | Sort -Property Published } # # Show-WindowsUpdate # Show-WindowsUpdate | Where { $_.isHidden }| Out-GridView Function Set-WindowsHiddenUpdate { [Cmdletbinding()] Param( [Parameter(ValueFromPipeline=$true,Mandatory=$true)] [System.__ComObject[]]$Update, [Parameter(Mandatory=$true)] [boolean]$Hide ) Process { $Update | ForEach-Object -Process { if ((($_.pstypenames)[0] -eq 'System.__ComObject#{c1c2f21a-d2f4-4902-b5c6-8a081c19a890}') -or (($_.pstypenames)[0] -eq 'System.__ComObject#{70cf5c82-8642-42bb-9dbc-0cfd263c6c4f}') -or (($_.pstypenames)[0] -eq 'System.__ComObject#{918efd1e-b5d8-4c90-8540-aeb9bdc56f9d}')) { try { $_.isHidden = $Hide Write-Verbose -Message "Blende Update $($_.Title) aus" } catch { Write-Warning -Message "Ausblenden des Windows Update fehlgeschlagen, Fehler $($_.Exception.Message)" } } else { Write-Warning -Message "Ignoriere uebergebenes Objekt" } } } } # Beispiel: verstecke alle noch offenene Updates # Get-WindowsUpdate | Set-WindowsHiddenUpdate -Hide:$true -Verbose # Beispiel: verstecke alle noch offenene Definitionsupdates # Get-WindowsUpdate | Where { $_.Title -match 'Definitionsupdate' } | Set-WindowsHiddenUpdate -Hide:$false # Beispiel: verstecke alle noch offenene sicherheitsupdates # Get-WindowsUpdate | Where { $_.Title -match 'Sicherheitsupdate' } | Set-WindowsHiddenUpdate -Hide:$false # Beispiel: verstecke Browser Choice Updates # Get-WindowsUpdate | Where { $_.Title -match 'Microsoft Browser Choice Screen Update'} | Set-WindowsHiddenUpdate -Hide $true -Verbose main ;:BatchExit ;REM Hinweis: dieses Ende des Batch Skriptes wird sofort ausgefuehrt, es wird nicht auf das Ende der Powershell gewartet! ;goto :eof # Stand 22.03.2021 # # Die Fehler sind / wurden wohl endgueltig mit folgendens Updates am 18.03 bzw. 22.03.2021 behoben # KB5001642 für Windows Server 2008 SP2 x64 (ESU) # http://download.windowsupdate.com/d/msdownload/update/software/updt/2021/03/windows6.0-kb5001642-x64_4ae1b3c5cebedcd27fe50add6a34e70a00d19b76.msu # KB5001639 für Windows 7 SP1 x86 (ESU) # http://download.windowsupdate.com/d/msdownload/update/software/updt/2021/03/windows6.1-kb5001639-x86_f7571200399e9c1099c37cc78c5b0a5481259989.msu # KB5001639 für Windows 7 SP1 x64 (ESU) # http://download.windowsupdate.com/d/msdownload/update/software/updt/2021/03/windows6.1-kb5001639-x64_de64f5cb314e3eac59bb3c4371c9ba802adf0f22.msu # KB5001639 für Windows Server 2008 R2 (ESU) # http://download.windowsupdate.com/d/msdownload/update/software/updt/2021/03/windows6.1-kb5001639-x64_de64f5cb314e3eac59bb3c4371c9ba802adf0f22.msu # KB5001641 für Windows Server 2012 x64 # http://download.windowsupdate.com/d/msdownload/update/software/updt/2021/03/windows8-rt-kb5001641-x64_ec0dc33ff8d0d0381eb3fe9595c8a96ccebf9e61.msu # KB5001640 für Windows 8.1 x86 # http://download.windowsupdate.com/d/msdownload/update/software/updt/2021/03/windows8.1-kb5001640-x86_149741dd2206faf42303dd7a6800567b681367be.msu # KB5001640 für Windows 8.1 x64 # http://download.windowsupdate.com/d/msdownload/update/software/updt/2021/03/windows8.1-kb5001640-x64_7aa82103f5e37a9d3c2ce2b608c903ed0855ac3b.msu # KB5001640 für Windows Server 2012 R2 # http://download.windowsupdate.com/d/msdownload/update/software/updt/2021/03/windows8.1-kb5001640-x64_7aa82103f5e37a9d3c2ce2b608c903ed0855ac3b.msu # KB5001631 für Windows 10 1507 und Server 2016 # KB5001634 für Windows 10 1803 # KB5001638 für Windows 10 1809 und Server 2019 # KB5001648 für Windows 10 1909 # KB5001649 für Windows 10 2004 und 20H2 # # fehlerhaft waren bisher die Updates KB5000802, KB5000808, KB5000822, KB5000809, KB5000812, KB5000803, KB5000807, KB5001567, KB5001566, KB5001568, KB5001565