WSUS Maintenance Utility

Clean up your WSUS! It's designed to run either on a WSUS server itself, or can be run from a remote machine. The computer that is running the utility must have the WSUS management PowerShell modules installed.

 
 
 
 
 
4.8 Star
(9)
8,948 times
Add to favorites
Windows Update
3/6/2020
E-mail Twitter del.icio.us Digg Facebook
  • Script never runs
    1 Posts | Last post February 01, 2020
    • All it says is wsus maintenance routine starting...
      Eventually it errors out:
      Invoke-WsusServerCleanup : The underlying connection was closed: A connection that was expected to be kept alive was
      closed by the server.
      At C:\scripts\Wsus-Maintenance.ps1:131 char:62
      + ... $WsusPort | Invoke-WsusServerCleanup -CleanupObsoleteComputers -Clean ...
      +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : InvalidData: (Microsoft.Updat...rCleanupCommand:InvokeWsusServerCleanupCommand) [Invoke-
         WsusServerCleanup], WebException
          + FullyQualifiedErrorId : ServerIsInvalid,Microsoft.UpdateServices.Commands.InvokeWsusServerCleanupCommand 
  • How often you would recommend to run the script?
    2 Posts | Last post November 08, 2019
    • Would once a month be sufficient enough? Or Once a week?
    • Personally, I run it daily.
      
      -Mike
  • Missing SSL Support
    2 Posts | Last post September 04, 2019
    • The script doesn't support ssl with wsus I've modified to be able to do so with a new switch that add -UseSsl to the Get-WSUSServer cmdlet
    • Thanks!
  • Script Execution Error
    2 Posts | Last post September 04, 2019
    • Hi,
      
      I tried to run the script on a Windows Server 2016 Standart, with WSUS ... and got the following error:
      
      Wsus-Maintenance.ps1 -Server wusSrv2016 -Port 8530 -L C:\Users\Administrator\Downloads
      Invoke-WsusServerCleanup : Execution Timeout Expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.
      The statement has been terminated.
      At C:\Users\Administrator\Downloads\Wsus-Maintenance.ps1:133 char:34
      + ... susServer | Invoke-WsusServerCleanup -CleanupObsoleteComputers -Clean ...
      +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : InvalidData: (Microsoft.Updat...rCleanupCommand:InvokeWsusServerCleanupCommand) [Invoke-WsusServerCleanup], SqlException
          + FullyQualifiedErrorId : UnexpectedError,Microsoft.UpdateServices.Commands.InvokeWsusServerCleanupCommand
      
      Any help please.
      Regards.
    • Hi there,
      
      Unfortunately WSUS is still WSUS and the purpose of this script is to automate the cleanup process. If you are getting time outs, rebooting the server and running the script again until it completes successfully is all I can suggest as it's what I do. After it's run successfully, scheduling it to run everyday should prevent future issues. However, from time to time it will still fail and you'll need to reboot and re-run it, as WSUS is still WSUS.
      
      Hope this helps.
  • It has not deleted anything
    2 Posts | Last post September 04, 2019
    • The script ran successfully but it has not deleted anything from the server.
    • Hi,
      
      Depending on how your server is setup it may not find anything to delete. This script just automates the cleanup process that is built into WSUS, it doesn't not replace it or improve it.
  • WSUS internal database
    4 Posts | Last post September 04, 2019
    • does it run with internal database?
    • Yes, it does.
    • Hi MIke, sorry to ask, but it didn´t delete anything?
    • Hi,
      
      Depending on how your server is setup it may not find anything to delete. This script just automates the cleanup process that is built into WSUS, it doesn't not replace it or improve it.
  • Timeout erros
    2 Posts | Last post September 04, 2019
    • Hi 
      
      Im also getting the same timeout errors
      
      WSUS maintenance routine starting...
      Invoke-WsusServerCleanup : Execution Timeout Expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.
      The statement has been terminated.
      At C:\temp\Wsus-Maintenance.ps1:126 char:62
      +     Get-WsusServer -Name $WsusServer -PortNumber $WsusPort | Invoke-WsusServerCl ...
      + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : InvalidData: (Microsoft.Updat...rCleanupCommand:InvokeWsusServerCleanupCommand) [Invoke-WsusServerCleanup], SqlException
          + FullyQualifiedErrorId : UnexpectedError,Microsoft.UpdateServices.Commands.InvokeWsusServerCleanupCommand
    • Hi there,
      
      Unfortunately WSUS is still WSUS and the purpose of this script is to automate the cleanup process. If you are getting time outs, rebooting the server and running the script again until it completes successfully is all I can suggest as it's what I do. After it's run successfully, scheduling it to run everyday should prevent future issues. However, from time to time it will still fail and you'll need to reboot and re-run it, as WSUS is still WSUS.
      
      Hope this helps.
  • Execution/TimeOut Errors
    2 Posts | Last post September 04, 2019
    • Have Tested on Server 2016 and 2012
      
      Receive the following timeout error in both
      
      Invoke-WsusServerCleanup : Execution Timeout Expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.
      At C:\Wsus-Maintenance\Wsus-Maintenance.ps1:127 char:62
      + ... $WsusPort | Invoke-WsusServerCleanup -CleanupObsoleteComputers -Clean ...
      +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : InvalidData: (Microsoft.Updat...rCleanupCommand:InvokeWsusServerCleanupCommand) [Invoke-WsusServerCleanup], SqlException
          + FullyQualifiedErrorId : UnexpectedError,Microsoft.UpdateServices.Commands.InvokeWsusServerCleanupCommand
      
      fo          : InvalidData: (:) [Send-MailMessage], ParameterBindingValidationException
          + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.SendMailMessage
      
    • Hi there,
      
      Unfortunately WSUS is still WSUS and the purpose of this script is to automate the cleanup process. If you are getting time outs, rebooting the server and running the script again until it completes successfully is all I can suggest as it's what I do. After it's run successfully, scheduling it to run everyday should prevent future issues. However, from time to time it will still fail and you'll need to reboot and re-run it, as WSUS is still WSUS.
      
      Hope this helps.
  • Execution error
    2 Posts | Last post September 04, 2019
    • Hi, I'm also seeing the same error as Ramazan, any idea why this is occurring?
      
      
      WSUS maintenance routine starting...
      Invoke-WsusServerCleanup : Timeout expired.  The timeout period elapsed prior to completion of the operation or the
      server is not responding.
      The statement has been terminated.
      At C:\scripts\Wsus-Maintenance.ps1:127 char:62
      +     Get-WsusServer -Name $WsusServer -PortNumber $WsusPort | Invoke-WsusServerCl ...
      + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : InvalidData: (Microsoft.Updat...rCleanupCommand:InvokeWsusServerCleanupCommand) [Invoke-
         WsusServerCleanup], SqlException
          + FullyQualifiedErrorId : UnexpectedError,Microsoft.UpdateServices.Commands.InvokeWsusServerCleanupCommand
      
    • Hi there,
      
      Unfortunately WSUS is still WSUS and the purpose of this script is to automate the cleanup process. If you are getting time outs, rebooting the server and running the script again until it completes successfully is all I can suggest as it's what I do. After it's run successfully, scheduling it to run everyday should prevent future issues. However, from time to time it will still fail and you'll need to reboot and re-run it, as WSUS is still WSUS.
      
      Hope this helps.
  • This script working on Windows Server 2008 R2?
    1 Posts | Last post November 12, 2018
1 - 10 of 12 Items