Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # WSUS Connection Parameters:
- [String]$updateServer = "server.domain.tld"
- [Boolean]$useSecureConnection = $False
- [Int32]$portNumber = 8530
- # Cleanup Parameters:
- # 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.
- [Boolean]$supersededUpdates = $True
- # Decline updates that aren't approved and have been expired by Microsoft.
- [Boolean]$expiredUpdates = $True
- # Delete updates that are expired and have not been approved for 30 days or more.
- [Boolean]$obsoleteUpdates = $True
- # Delete older update revisions that have not been approved for 30 days or more.
- [Boolean]$compressUpdates = $True
- # Delete computers that have not contacted the server in 30 days or more.
- [Boolean]$obsoleteComputers = $True
- # Delete update files that aren't needed by updates or downstream servers.
- [Boolean]$unneededContentFiles = $True
- # Load .NET assembly
- [void][reflection.assembly]::LoadWithPartialName("Microsoft.UpdateServices.Administration")
- # Connect to WSUS Server
- Write-Host "Connecting to WSUS Server | "$updateServer":"$portNumber
- $Wsus = [Microsoft.UpdateServices.Administration.AdminProxy]::getUpdateServer($updateServer,$useSecureConnection,$portNumber)
- # Perform Cleanup
- $CleanupManager = $Wsus.GetCleanupManager()
- $CleanupScope = New-Object Microsoft.UpdateServices.Administration.CleanupScope($supersededUpdates,$expiredUpdates,$obsoleteUpdates,$compressUpdates,$obsoleteComputers,$unneededContentFiles)
- Write-Host "Performing clean up tasks.. Please wait.."
- $CleanupManager.PerformCleanup($CleanupScope)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement