Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MaySoMusician/23c6943a5393c87161a6fffa544dbf3e to your computer and use it in GitHub Desktop.
Save MaySoMusician/23c6943a5393c87161a6fffa544dbf3e to your computer and use it in GitHub Desktop.
How to *hide* (prevent Windows from installing) the particular updates with Powershell. https://qiita.com/MaySoMusician/items/f239197283f4a8ad9811
#Requires -RunAsAdministrator
# Must run this as an administrator!
# Based on the official wushowhide.diagcab
$target = "2021-03 Cumulative Update for Windows 10 Version 20H2 for x64-based Systems (KB5000802)"
Write-Host ""
Write-Host "This program will *hide* (prevent Windows from installing) the following update"
Write-Host " - '$target'."
Write-Host ""
Write-Host -NoNewLine "Are you sure you want to proceed? (y/N) "
$confirm = [System.Console]::ReadKey()
Write-Host ""
if ($confirm.Key -ne "Y") {
Write-Host ""
Write-Host Operation cancelled.
exit 1
}
Write-Host ""
Write-Host "Operation started."
Write-Host ""
Write-Host "Searching the update..."
$session = New-Object -ComObject Microsoft.Update.Session
$searcher = $session.CreateUpdateSearcher()
$updates = $searcher.Search("IsInstalled=0").Updates
$run = $false
foreach($update in $updates){
if ($update.Title -eq $target){
Write-Verbose "Attempting to hide $(($update).Title)"
$update.IsHidden = $true
Write-Verbose "Set IsHidden to '$($update).IsHidden)'"
$run = $true
}
}
Write-Host ""
if ($run) {
Write-Host "Operation finished successfully."
} else {
Write-Host "FAILED: update not found"
exit 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment