The function Remove-KBPackage
that we are going to create will search and uninstall Windows Update packages based on the provided KB (Knowledge Base) number.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | function Remove-Package { param ( [string] $KB ) # Recherche du ou des packages $packages = Get-WindowsPackage -Online | Where-Object { $_ .PackageName -match $KB } if ( $packages .Count -eq 0) { Write-Host "No packages found matching $KB." return } # Affichage des packages trouvés Write-Host "Packages found matching $KB" $packages | ForEach-Object { Write-Host $_ .PackageName } # Suppression des packages foreach ( $package in $packages ) { try { Write-Host "Uninstalling $($package.PackageName)..." Remove-WindowsPackage -Online -PackageName $package .PackageName -NoRestart -ErrorAction Stop Write-Host "$($package.PackageName) uninstalled successfully." } catch { Write-Error "Failed to uninstall $($package.PackageName). Error: $_" } } Write-Host "Please restart your computer." } # Exemple d'utilisation Remove-Package -KB "KB4589210" |
If you want to uninstall a Cumulative Update, first identify the Windows version.
For example, to uninstall the update from November 14, 2023, Use Remove-Package -KB “KB17763.5122”

0 Comments