Kaseya Community

E-mail when machine group is completed patching

  • Hello Kaseya Forum!!

    I am hoping one of you wizards of Kaseya can be of assistance.

    I currently have a client with several machine groups that patch throughout the weekends.  The client is now requesting a completion e-mail when the machine groups are completely patched.   The machines patch at 11PM, 1AM, 3AM, 5AM, 6AM, and 8AM.  It would be obnoxious to manually send an e-mail at each patch interval with a status update.

    I know how to use the Send-Mail agent procedure to send an e-mail post patch procedure for a single machine id.

    Does anyone know of a way to send an e-mail when an entire group has completed the patch procedure?

  • Maybe use procedures to update a global variable and when the global variable reaches a certain value send them email and clear out the global variable: help.kaseya.com/.../9030000

    Or, you could have it email an email address and have PHP (or other language) check the inbox and once emails for all groups are there, send the email and then use PHP to delete the emails in the inbox.  

  • There's no built-in way to detect when all machines complete the patch cycle. you can only do it on a per-machine basis witihn the VSA's built-in functionality.

    I would do it via an SQL query in an agent procedure, see help.kaseya.com/.../9030000

    I'd set an agent procedure to run post-patch, and then in the SQL query, check if all agents in that machine group are done updating (i.e. no pending patches).

    Let me know if you need help writing the SQL query...

  • Hi Craig,

    I like the SQL query idea.  

    I would definitely need some assistance in writing the query.  

    I'm eager to learn and want to build my skill set.

  • Here is the query I used to get er' done.

    /*###DELARE VARIABLE##*/
    DECLARE @PatchRemaining int
    SET @PatchRemaining =
        (SELECT PatchRemaining
                FROM (SELECT [ReverseGroupName],
                        SUM(pending) As PatchRemaining
                        FROM [ksubscribers].[dbo].[vPatchStatusByAgent]
                        WHERE [ReverseGroupName] like '%cavesandbox%'
                        GROUP BY [ReverseGroupName])
        As PatchRemaining)
    /*##SET WHILE LOOP##*/
    WHILE (@PatchRemaining !=0)
    BEGIN
    SET @PatchRemaining =
        (SELECT PatchRemaining
                FROM (SELECT [ReverseGroupName],
                        SUM(pending) As PatchRemaining
                        FROM [ksubscribers].[dbo].[vPatchStatusByAgent]
                        WHERE [ReverseGroupName] like '%cavesandbox%'
                        GROUP BY [ReverseGroupName])
                As PatchRemaining)
    IF @PatchRemaining = 0
    BREAK;
    END

    /*##SEND MAIL###*/
    USE msdb
    GO
    EXEC sp_send_dbmail @profile_name='Managed Services',
    @recipients='kohen.dubeau@sandbox.com',
    @subject='Patch Managment E-mail TEST',
    @body='This is a test, patch cycle has completed successfully.'