Advertisement
Guest User

WSUS CLEAN

a guest
Dec 5th, 2019
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. $WSUSserver = Get-WsusServer -Name osd-wsus02 -PortNumber 8530
  2. Write-Progress -Activity 'Getting unapproved needed updates...' -PercentComplete 0
  3. $updatesneeded = Get-WsusUpdate -UpdateServer $WSUSserver -Approval Unapproved -Status needed
  4. $i = 0
  5. $total = $updatesneeded.Count
  6. foreach ($update in $updatesneeded)
  7. {
  8. Write-Progress -Activity 'Approving needed updates...' -Status "$($update.Update.Title)" -PercentComplete (($i/$total) * 100)
  9. Approve-WsusUpdate -Update $update -Action Install -TargetGroupName 'all computers'
  10. $i++
  11. }
  12. Write-Host "Updates approved: $total" -ForegroundColor Yellow
  13. Write-Progress -Activity 'Getting unapproved not needed updates...' -PercentComplete 0
  14. $updatesNOTneeded = Get-WsusUpdate -UpdateServer $WSUSserver -Approval Unapproved -Status InstalledOrNotApplicable
  15. $i = 0
  16. $total = $updatesNOTneeded.Count
  17. foreach ($update in $updatesNOTneeded)
  18. {
  19. Write-Progress -Activity 'Denying updates not needed...' -Status "$($update.Update.Title)" -PercentComplete (($i/$total) * 100)
  20. Deny-WsusUpdate -Update $update
  21. $i++
  22. }
  23. Write-Host "Declined updates: $total" -ForegroundColor Yellow
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement