How To Schedule WSUS Server Cleanup

IT Support Forum Forums Windows Windows Server 2012 General Discussion How To Schedule WSUS Server Cleanup

This topic contains 0 replies, has 1 voice, and was last updated by  Webmaster 9 months, 3 weeks ago.

  • Author
    Posts
  • #1706

    Webmaster
    Keymaster

    Did you know that the WSUS Server Cleanup Wizard tasks can be scheduled? To schedule WSUS Server Cleanup tasks, create a PowerShell script (.ps1 file) with the following code:

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

    You can then schedule this task using the Windows Task Scheduler, but make sure you tick the box to run the task with highest privileges, otherwise you’ll get an error saying Request For Principal Permission Failed.

    ❗ Note: To schedule a PowerShell script to run, you have to have the program / script set to run “PowerShell”, then specify the location of the ps1 file in the “Start In” box, then put the name of the script as an argument, in the format .\scriptname.ps1. Otherwise, your PowerShell scheduled task will either continuously run forever or end with an error code of 0x1.

    When the scheduled task runs, it will perform the WSUS Server Cleanup tasks.

You must be logged in to reply to this topic.