Forum Discussion
PowerShell Novice: Script Timeout #WSUS
Hi
I'm an idiot. Have to say this at the beginning so you are ready to help a moron understand what is happening!!! And in plain English, or crayon......
I'm trying to schedule a PowerShell script to clean up my WSUS which is proving to be a pain to keep on top of.......little bit of research and I find the following basic script which appears to do what I need, however I get a red warning that this basically times out and then fails in its task.
Is my script too basic and I am expecting too much, or can the time frame be increased to allow it to do what it needs to do?! I don't want to pay for the infamous AdamJ script and had hoped WSUS would be developed further by now to accommodate such cleaning tasks....but hey ho!
Any help would be most welcome...thanks!!
Get-Date >> E:\WSUS_Logs\WSUS_Decline.txt
Get-WsusServer | Invoke-WsusServerCleanup -DeclineExpiredUpdates -DeclineSupersededUpdates >>E:\WSUS_Logs\WSUS_Decline.txt
and a second script for the following
Get-Date >> E:\WSUS_Logs\WSUS_Cleanup.txt
Get-WsusServer | Invoke-WsusServerCleanup -CleanupObsoleteComputers -CleanupObsoleteUpdates -CleanupUnneededContentFiles >>E:\WSUS_Logs\WSUS_Cleanup.txt
7 Replies
- LainRobertsonSilver Contributor
For many years now, WSUS performance has suffered from missing indexes out-of-the-box.
The System Center product group have for a long time now published a guide on how you can add these missing indexes to the WSUS database. Speaking from experience, this advice from the product is a "must do" post installation task as the performance difference is profound.
Here's the documentation where you can find the T-SQL script in step 3:
Cheers,
Lain
- Taff4EverCopper ContributorThanks for the info and of course Google has given me some ideas on this, but my issues is what I should be adding to the script and where it should be.
I can’t seem to find a way to ensure there is no timeout for this as much of what I’ve read shows a specific time frame and wondered if it was possible.
I’m a complete novice with this so appreciate any feedback- LainRobertsonSilver Contributor
You can't change the script, unfortunately.
The error itself is an SQL error, and you have no capacity for controlling the query timeout.
But by applying the indexes from the above article, you improve SQL performance on the WSUS database quite considerably (for certain functions), which greatly shortens the time it takes to finish, which in turn resolves this error condition.
In other words, you can't tackle this from the client side. You need to address it from the database server side.
Cheers,
Lain
- AndySvintsSteel Contributor
Hello Taff4Ever,
For starters, please try to run separate cleaning tasks for each parameter. If you will still receive timeout error for individual parameters, please look into increasing timeouts, as it mentioned in references.
References:
WSUS cleanup aborting: Increase timeout for database and IIS
P.S. I am not gonna lie this info is from the 1st page of Google search.
Hope that helps.
- Alex_RechsCopper ContributorHi,
It could be not an answer you desire, but I found a lot of workaround when googled the following:
"Invoke-WsusServerCleanup" timeout