Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Search for Optional updates (it may also offer the non-security cumulative update in certain scenarios)
- $Criteria = "IsInstalled=0 and DeploymentAction='OptionalInstallation'"
- # Search for Optional Feature Update (better)
- $Criteria = "DeploymentAction='OptionalInstallation' and CategoryIDs contains '3689bdc8-b205-4af4-8d4a-a63924c5e9d5'"
- # Start the Search
- $Session = new-object -com "Microsoft.Update.Session"
- $Result = $Session.CreateupdateSearcher().Search($Criteria)
- # Show updates details
- $Result.Updates | Select Title,Identity,IsHidden,LastDeploymentChangeTime,KBArticleIDs | Format-List -Property Title,@{l='UpdateID';e={$_.Identity.UpdateID}},@{l='PublishedDate';e={$_.LastDeploymentChangeTime.ToString('yyyy-MM-dd')}},@{l='KBArticle';e={$_.KBArticleIDs}},IsHidden
- # Hide all updates
- Foreach ($Update in $Result.Updates) {if ($Update.IsHidden -eq $false) {Write-Host "Hiding update: $($Update.Title)"; $Update.IsHidden = $true} else {Write-Host "Already hidden: $($Update.Title)"}}
- # Hide specific update (get UpdateID from details)
- $($Result.Updates | Where-Object {$_.Identity.UpdateID -EQ '63c4af5d-5f8a-4dbb-aeae-cf65424bfb16'}).IsHidden = $true
- # Unhide specific update (get UpdateID from details)
- $($Result.Updates | Where-Object {$_.Identity.UpdateID -EQ '63c4af5d-5f8a-4dbb-aeae-cf65424bfb16'}).IsHidden = $false
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement