Auto-commit: 2025-10-31 08:55:43
This commit is contained in:
19
uninstall-kb-remove-windows-package/readme.md
Normal file
19
uninstall-kb-remove-windows-package/readme.md
Normal file
@@ -0,0 +1,19 @@
|
||||
# Remove Windows Updates by KB (PowerShell)
|
||||
|
||||
Uninstalls all installed Windows packages whose name matches a given **KB** via DISM PowerShell cmdlets.
|
||||
|
||||
## Usage
|
||||
```powershell
|
||||
# List installed packages and filter by KB
|
||||
Get-WindowsPackage -Online | Where-Object { $_.PackageName -match "KB5032189" } | Select-Object PackageName, State, InstallTime
|
||||
```
|
||||
|
||||
```powershell
|
||||
# Uninstall all packages matching the KB
|
||||
Remove-Package -KB "KB4589210"
|
||||
```
|
||||
|
||||
## Notes & limitations
|
||||
MSU files: Remove-WindowsPackage removes packages in the image (.cab/package identities), not .msu directly
|
||||
SSUs can’t be uninstalled: Servicing Stack Updates modify the update stack and are not removable.
|
||||
After ResetBase: If you ran DISM /Online /Cleanup-Image /StartComponentCleanup /ResetBase, existing update packages can no longer be uninstalled.
|
||||
33
uninstall-kb-remove-windows-package/remove.ps1
Normal file
33
uninstall-kb-remove-windows-package/remove.ps1
Normal file
@@ -0,0 +1,33 @@
|
||||
function Remove-Package {
|
||||
param(
|
||||
[string]$KB
|
||||
)
|
||||
|
||||
# Find matching package(s)
|
||||
$packages = Get-WindowsPackage -Online | Where-Object { $_.PackageName -match $KB }
|
||||
|
||||
if($packages.Count -eq 0) {
|
||||
Write-Host "No packages found matching $KB."
|
||||
return
|
||||
}
|
||||
|
||||
# Display found packages
|
||||
Write-Host "Packages found matching $KB"
|
||||
$packages | ForEach-Object { Write-Host $_.PackageName }
|
||||
|
||||
# Uninstall 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."
|
||||
}
|
||||
|
||||
# Example usage
|
||||
Remove-Package -KB "KB4589210"
|
||||
Reference in New Issue
Block a user