WSUS automated cleanup script

The script runs WSUS cleanup tasks using stored procedures in WSUS database directly, avoiding timeout errors and WSUS service crash that may occur when using WSUS' Cleanup Wizard.

 
 
 
 
 
4.6 Star
(8)
6,283 times
Add to favorites
Windows Update
3/12/2018
E-mail Twitter del.icio.us Digg Facebook
Sign in to ask a question


  • Connection Error
    1 Posts | Last post December 03, 2018
    • Hi,
      
      I got errors while trying to run the script.
      
      OS: Windows Server 2016 Standart
      Server Version: 10.0.14393.2608
      DB: WID
      
      Error Message:
      wsus-cleanup-updates-v4.ps1
      
      Connecting to database SUSDB on MICROSOFT##WID
      Unhandled exception:
      Exception calling "Open" with "0" argument(s): "A network-related or instance-specific error occurred while establishing a connection to SQL Server. The
       server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (pr
      ovider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)"
      Completed script execution with 1 error(s)
      Execution time 0 hours and 0 minutes.
      
  • Error message
    1 Posts | Last post November 03, 2018
    • This is the output I receive:
      
      Connecting to database SUSDB on MICROSOFT##WID
      Declining expired updates
      Unhandled exception:
      Cannot validate argument on parameter 'Message'. The argument length of 19027271 is too long. Shorten the length of the
      argument to less than or equal to "32766" and then try the command again.
      Completed script execution with 2 error(s)
      Execution time 1 hours and 60 minutes.
      
      WS2012 WSUS, using WID
  • Connection error
    2 Posts | Last post October 11, 2018
    • I also receive the same error "xception calling "Open" with "0" argument(s): "A network-related or instance-specific error occurred while establishing
      " . I have found this error is only on Server 2008 and Server 2008R2 systems, the script is working wel on later server versions. Is there something to change in the script for Server 2008/2008R2 to work?
      
      Thank you
    • I am seeing the following error for each of the updates slated for deletion:
      Deleting update 250406 (134 of 4525)
      Error deleting update 250406:
      Exception calling "ExecuteNonQuery" with "0" argument(s): "@errorMessage
      spDeleteUpdate got error from spDeleteRevision"
      
      Windows Server 2016, WSUS 10.0.14393.2485 using WID
  • Error database
    2 Posts | Last post October 05, 2018
    • Hello,
      When run the script after some seconds i recieve this error >
      
      Connecting to database SUSDB on WSUS\MICROSOFT##SSEE
      Unhandled exception:
      Exception calling "Open" with "0" argument(s): "A network-related or instance-specific error occurred while establishing
       a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct an
      d that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open
       a connection to SQL Server)"
    • Could you please provide more details about your setup? OS version, WSUS version, WSUS db config?