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.
There are a few notes to this script:
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.
.
This website uses cookies.
View Comments
This got me out of the dreaded 'Server node reset' errors. Thank you!
worked like a charm (Win2019). Thanks
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.
I am sorry to say we are only aware of the PS code requiring the latest PowerShell :(
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 *
I am also running 08 r2, running as admin, and the commands don't work for me either.
Hi Kevin;
Are you running the a current version of PowerShell? These commands require the updated PS builds.