Advertisement
Ibra86

1909 OptionalInstallation

Nov 19th, 2019
886
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Search for Optional updates (it may also offer the non-security cumulative update in certain scenarios)
  2. $Criteria = "IsInstalled=0 and DeploymentAction='OptionalInstallation'"
  3.  
  4. # Search for Optional Feature Update (better)
  5. $Criteria = "DeploymentAction='OptionalInstallation' and CategoryIDs contains '3689bdc8-b205-4af4-8d4a-a63924c5e9d5'"
  6.  
  7. # Start the Search
  8. $Session = new-object -com "Microsoft.Update.Session"
  9. $Result = $Session.CreateupdateSearcher().Search($Criteria)
  10.  
  11. # Show updates details
  12. $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
  13.  
  14. # Hide all updates
  15. 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)"}}
  16.  
  17. # Hide specific update (get UpdateID from details)
  18. $($Result.Updates | Where-Object {$_.Identity.UpdateID -EQ '63c4af5d-5f8a-4dbb-aeae-cf65424bfb16'}).IsHidden = $true
  19.  
  20. # Unhide specific update (get UpdateID from details)
  21. $($Result.Updates | Where-Object {$_.Identity.UpdateID -EQ '63c4af5d-5f8a-4dbb-aeae-cf65424bfb16'}).IsHidden = $false
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement