When patching operations fail with exit code 340 the root cause is probably related to the fact that your WSUS server needs a cleanup !
If the output of the patching execution activity contains the following we suggest to perform several maintenance operations.
Exception calling "GetUpdates" with "1" argument(s): "The operation has timed
At C:\Program Files\Intigua\vAgentManager\temp\Runnables\Runnables\aded2ea7-fd1
+ $allUpdates = $wsus.GetUpdates($UpdateScope) | Sort-Object -Property
Recommended Maintenance operations on WSUS
- Check if there is sufficient disk space , CPU consumption, Memory leak, connectivity checks and usual IT concerns..
- Try to reboot the WSUS Server
- run the command wsusutil.exe checkhealth and check the output to see if there are any errors.
- run the command wsusutil.exe rest and see if it fixes the issue.
If the above steps were not helpful and you are still getting exit code 340 from patch installation procedures please perform the following -
Advanced Maintenance and Optimization process for WSUS
Manually Identify and decline superseded updates in WSUS
It's recommended to clean manually all superseded updates in order to clean your WSUS infrastructure.
1. Open the Windows Update Services MMC then select the All Updates View as you can see below.
2. Set the display to show the Approval status of ‘Any except Declined’ with a Status of ‘Any’, then Click Refresh.
3. Right-click in the title bar and Enable the ‘Supersedence’ column to make it visible.
4. Select and Decline the Superseded Updates
The updates to be declined have one of two particular flowchart symbols for their updates pictured in the attached image. Select the correct updates and Decline them by either right-clicking the selected updates and clicking decline or by pressing the decline button in the action pane.
Now there are 4 options:
- No icon: update doesn’t supersede another one nor is it superseded by an update.
- Blue square on top: this update supersedes another update, Do not clean these updates !!!
- Blue square in the middle: this update has been superseded by another update and superseded another update as well, this is an example of an update you may want to clean (decline).
- Blue square in the right below corner: this update has been superseded by another update, this is an example of an update you may want to clean (decline).
Clean unused files
Cleaning unused files will remove the files physically present on the server.
We will find in these files the replaced updates that were refused.
From the Administration Console, click Options and then click Server Cleanup Wizard.
The first step in the wizard will be to select the updates you would like to clean. Check only the 'Uneeded update files' checkbox and click next.
Once the cleaning process is completed, click on the Finish button to close the wizard. In the summary you will find the free space details.
Reindexing the database
In order to maintain optimal database performance, it is necessary to reindex the database.
A script for the following steps is available on the Technet website at this address: https://gallery.technet.microsoft.com/scriptcenter/6f8cde49-5c52-4abd-9820-f1d270ddea61
1. Start Microsoft SQL Server Management Studio and connect to the base instance where the WSUS database is running.
Note: If you are using the Windows internal database, you must install Microsoft SQL Server Management Studio on the WSUS server and use as server name :
\\.\pipe\Microsoft##WID\tsql\query using Windows authentication.
2. Right-click on SUSDB  and click on New Query .
3. Paste the script into the query box 1 and click on Run 2.
Wait while the request is being processed. Once the query is executed, the result is displayed under 
Reduce the size of the base
Always from SSMS, right click on the database SUSDB 1 then go to Tasks 2 / Reduce 3 and click on Database 4.
Click OK 1 to start the database reduction.
Once optimization is complete, the window closes automatically.