Advertisement
Guest User

Untitled

a guest
May 18th, 2018
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # WSUS Connection Parameters:
  2. [String]$updateServer = "server.domain.tld"
  3. [Boolean]$useSecureConnection = $False
  4. [Int32]$portNumber = 8530
  5.  
  6. # Cleanup Parameters:
  7. # Decline updates that have not been approved for 30 days or more, are not currently needed by any clients, and are superseded by an aproved update.
  8. [Boolean]$supersededUpdates = $True
  9. # Decline updates that aren't approved and have been expired by Microsoft.
  10. [Boolean]$expiredUpdates = $True
  11. # Delete updates that are expired and have not been approved for 30 days or more.
  12. [Boolean]$obsoleteUpdates = $True
  13. # Delete older update revisions that have not been approved for 30 days or more.
  14. [Boolean]$compressUpdates = $True
  15. # Delete computers that have not contacted the server in 30 days or more.
  16. [Boolean]$obsoleteComputers = $True
  17. # Delete update files that aren't needed by updates or downstream servers.
  18. [Boolean]$unneededContentFiles = $True
  19.  
  20. # Load .NET assembly
  21. [void][reflection.assembly]::LoadWithPartialName("Microsoft.UpdateServices.Administration")
  22.  
  23. # Connect to WSUS Server
  24. Write-Host "Connecting to WSUS Server | "$updateServer":"$portNumber
  25. $Wsus = [Microsoft.UpdateServices.Administration.AdminProxy]::getUpdateServer($updateServer,$useSecureConnection,$portNumber)
  26.  
  27. # Perform Cleanup
  28. $CleanupManager = $Wsus.GetCleanupManager()
  29. $CleanupScope = New-Object Microsoft.UpdateServices.Administration.CleanupScope($supersededUpdates,$expiredUpdates,$obsoleteUpdates,$compressUpdates,$obsoleteComputers,$unneededContentFiles)
  30. Write-Host "Performing clean up tasks.. Please wait.."
  31. $CleanupManager.PerformCleanup($CleanupScope)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement