Tuesday, August 7, 2018

Automate WSUS Server Cleanup on Windows Server 2016 with PowerShell

I had a task to automate wsus server cleanup on windows server 2016.
For this task I used one windows server 2016 powershell command

Invoke-WsusServerCleanup

Invoke-WsusServerCleanup performs the process of cleanup on a specified WSUS server. This process has the same impact as running the Cleanup Wizard from the WSUS Console and allows the specification of the same options as Cleanup Wizard.

In my case I added tasks in Task Scheduler on WSUS Server to run powershell with command:

Task 1. 
Name: WSUS-Cleanup
Task running: Weekly
Description: Cleanup obsolete computers and obsolete updates, delete unneeded updates and obsolete revisions to updates, declines expired updates, declines superseded updates
Command:

[PS]Get-WsusServer | Invoke-WsusServerCleanup -CleanupObsoleteComputers -CleanupObsoleteUpdates -CleanupUnneededContentFiles -CompressUpdates -DeclineExpiredUpdates -DeclineSupersededUpdates


Task 2.
Name: WSUS-Cleanup-Computers 
Task running: Daily
Description: Cleanup for obsolete computers
Command:

[PS]Get-WsusServer | Invoke-WsusServerCleanup -CleanupObsoleteComputers



No comments:

Post a Comment