Categories: Windows Server

SOLVED: How To Force a Clean Up of WSUS Data & Resolve SERVER NODE RESET Using PowerShell

wsus-reset-server-node-error-connection-errorwsus-reset-server-node-error-connection-errorUpdated: January 2022

If you cannot complete a clean up of your WSUS server through the WSUS console because it keeps erroring out with SERVER NODE RESET, you can hopefully complete through the following PowerShell command line:

Invoke-WsusServerCleanup -DeclineSupersededUpdates -DeclineExpiredUpdates -CleanupObsoleteComputers -CleanupObsoleteUpdates -CleanupUnneededContentFiles -CompressUpdates

If this fails or times out, you can run each of the commands one by one:

Invoke-WsusServerCleanup -CleanupUnneededContentFiles -CompressUpdates
Invoke-WsusServerCleanup -DeclineSupersededUpdates
Invoke-WsusServerCleanup -DeclineExpiredUpdates
Invoke-WsusServerCleanup -CleanupObsoleteComputers
Invoke-WsusServerCleanup -CleanupObsoleteUpdates -CompressUpdates

Whichever command you finish on should include -CompressUpdates because that is the command which actually deletes the garbage from the database.

If you want to know what the switches are for INVOKE-WSUSSERVERCLEANUP, skim through THIS Microsoft article.

powershell-cleanup-wsus-server-node-reset-fixpowershell-cleanup-wsus-server-node-reset-fixNote that if your WSUS database is corrupted or has other issues, you will want to run WSUS Database cleanup as we describe HERE.

There are a few notes to this script:

  1. You need to run POWERSHELL as an Admin
    .
  2. If you see the following error go to your SERVICES and start WSUS Certificate Server or just type NET START WSusCertServer
    Invoke-WsusServerCleanup : The service cannot be started, either because it is disabled or because it has no enabled devices associated with it
    .
  3. As you can see in the screen shot my first round at this failed.  I also had .NET error the appeared which I mistakenly cleared before reading carefully.  Then I shortened up the script to do less:

Invoke-WsusServerCleanup  -CleanupUnneededContentFiles -CompressUpdates

Then I ran the other half of the script:

Invoke-WsusServerCleanup -DeclineSupersededUpdates -DeclineExpiredUpdates -CleanupObsoleteComputers -CleanupObsoleteUpdates

Then I ran the entire script again, which apparently did nothing.  After that I was able to the WSUS SERVER CLEAN UP WIZARD from the WSUS console without problem.

.

I found some information on this command HERE and HERE.

View Comments

  • Hello, does this solution apply to WinSer2019? because I tried 3 times and this error occurs in PowerShell.

    Invoke-WsusServerCleanup: Execution Timeout Expired. The timeout period ended before completion
    operation or the server is not responding.
    The instruction has ended.
    In line: 1 character: 18
    + ... susServer | Invoke-WsusServerCleanup -DeclineSupersededUpdates -Decli ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~
    + CategoryInfo: InvalidData: (Microsoft.Updat ... rCleanupCommand: InvokeWsusServerCleanupCommand) [Invoke-
    WsusServerCleanup], SqlException
    + FullyQualifiedErrorId: UnexpectedError, Microsoft.UpdateServices.Commands.InvokeWsusServerCleanupCommand

    • Hi Tiago;

      I do not have a Server 2019 box but I doubt it is different as WSUS has not changed from version 3 in years. I no longer have access to a WSUS box as several of my customers just shut down due to COVID and world oil prices; the next time I expect to have my hands on one is in December and that is likely too late to assist.

  • Is there a version of this that works with Powershell Version 2? Installing any newer version of Powershell on SBS 2011 or earlier will break things - badly.

  • Hi,

    The screenshot shows the reverse of what you state in step 3, i.e.:

    First you ran:

    Invoke-WsusServerCleanup -DeclineSupersededUpdates -DeclineExpiredUpdates -CleanupObsoleteComputers -CleanupObsoleteUpdates

    Then you ran:

    Invoke-WsusServerCleanup -CleanupUnneededContentFiles -CompressUpdates

    And then you ran the whole script.

    Just clarifying....

    Thanks, in advance.
    Stephen

  • Hey,

    I just stumbled across this post and it looks fantastic.
    I have a 2008R2 server with WSUS and powershell 4.0 on it. When I try to run the 'Invoke-WsusServerCleanup' command I get this error:
    The term 'Invoke-WsusServerCleanup' is not recongized as the name of a cmdlet, function, script file...

    Can you point me in the right direction?

    Thanks

    • Two things come to mind. 1: Are you running PowerShell as an Admin (not just logged into Windows as an Admin, but running the PowerShell app as an Admin) 2: See if you can access any WSUS PowerShell commands like: Get-WSUSServer | fl *