Guest User

Untitled

a guest
May 22nd, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. $WsusServer = "localhost"
  2. $UseSSL = $false
  3. $PortNumber = 8530
  4.  
  5. #Connect to the WSUS interface.
  6. [reflection.assembly]::LoadWithPartialName("Microsoft.UpdateServices.Administration") | out-null
  7. $WsusServerAdminProxy = [Microsoft.UpdateServices.Administration.AdminProxy]::GetUpdateServer($WsusServer,$UseSSL,$PortNumber);
  8.  
  9. #Create Object for WSUS Server
  10. $CleanUpScope = New-Object Microsoft.UpdateServices.Administration.CleanupScope
  11.  
  12. #Define Scope for cleanup by setting on true / false
  13. $CleanUpScope.CleanupObsoleteUpdates = $true
  14. $cleanUpScope.CleanupObsoleteComputers = $true
  15. $cleanUpScope.CleanupUnneededContentFiles = $true
  16. $cleanUpScope.DeclineExpiredUpdates = $true
  17. $cleanUpScope.DeclineSupersededUpdates = $false
  18. $cleanUpScope.CompressUpdates = $true
  19.  
  20. #create object for cleanup manager
  21. $cleanUpManager = $WsusServerAdminProxy.GetCleanupManager()
  22.  
  23. #trigger cleanup
  24. $CleanUpManager.PerformCleanup($cleanupScope)
Add Comment
Please, Sign In to add comment