none
WSUS - need to trigger a script when new updates are synchronised.

    Question

  • I have a single WSUS server running on 2012R2, using WID rather than full SQL. WSUS is set to synchronise on a schedule. I want to be able to trigger a PowerShell script when a synchronisation has resulted in new updates being downloaded. However, I can't find a way to do this. So far I have looked at:

    WSUS console: The only related setting I can find is notification by email.

    Scheduled task: WSUS adds a random offset of up to 30 minutes to the synchronisation times, so I can't schedule a task to accurately coincide with the synchronisation.

    Event Log: When I first started this, I naively assumed WSUS would be logging information events when it synchronised and that I would be able to make an event-triggered scheduled task. However, I cannot find any such events in the Windows event log, or any mention of relevant event IDs from Googling. I've found references to event IDs for various synchronisation errors, but nothing for normal, successful synchronisation.

    I've found tantalising references in SoftwareDistribution.log such as:

    "EventLogEventReporter.ReportEvent EventId=384,Type=Information,Category=Synchronization,Message=Synchronization completed successfully."

    However there is no event 384 showing in my Event Log, so I assume that the above refers to some kind of internal WSUS event log.

    So - if I'm missing something about WSUS event logging, or if anyone can suggest any other way to trigger a script when WSUS synchronises new updates I'd be really grateful.

    Thank you!


    Friday, April 21, 2017 2:25 PM

Answers

All replies

  • maybe another way of thinking about it..

    instead of using the WSUS built-in sync-scheduler, configure your WSUS for manual-sync, and then could you use a schedule task to launch PoshWSUS to start a sync and it then executes your 'other script' ?

    https://github.com/proxb/PoshWSUS/blob/master/Scripts/Start-PSWSUSSync.ps1


    Don [doesn't work for MSFT, and they're probably glad about that ;]

    Saturday, April 22, 2017 10:46 AM
  • Hi ObfuscatedClarity,

    Maybe you could use powershell command to trigger the WSUS synchronization, then add the powershell command into the script you want to run after synchronization, then add the script into Task schedule. In another word, integrated the two behavior into one script.

    Another thought is to use process monitor to check the detailed process of WSUS synchronization, then find the key process to be a trigger condition.

    Best Regards,

    Anne


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Tuesday, April 25, 2017 2:46 AM
    Moderator
  • maybe another way of thinking about it..

    instead of using the WSUS built-in sync-scheduler, configure your WSUS for manual-sync, and then could you use a schedule task to launch PoshWSUS to start a sync and it then executes your 'other script' ?

    https://github.com/proxb/PoshWSUS/blob/master/Scripts/Start-PSWSUSSync.ps1


    Don [doesn't work for MSFT, and they're probably glad about that ;]

    Thanks Don, that's not a bad shout - think I'd probably got a bit fixated on one way of doing it without taking a step back. Thanks for the link too, I'll definitely take a closer look at PoshWSUS.

    Tuesday, April 25, 2017 9:02 AM
  • Hi ObfuscatedClarity,

    If the above reply could be of help, you may mark the useful one as answer.

    Best Regards,

    Anne


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.


    Wednesday, May 03, 2017 7:01 AM
    Moderator
  • Hi ObfuscatedClarity,

    If the above reply could be of help, you may mark the useful one as answer.

    Best Regards,

    Anne


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.


    Certainly will. Was just giving it a couple of days in case anyone else had anything to add, and then had a bit of a mad week at work, just catching up with everything.

    Best,

    Chris.


    Wednesday, May 03, 2017 8:24 AM