Share via

Summary emails

TBingeman 81 Reputation points
2021-08-27T17:13:45.377+00:00

I have a runbook that is going to multiple servers to run a script. I have it set up to use concurrency but I need to make sure that we know the results of the script ran on each server in a single email instead of receiving 1.2k emails when the runbook runs. I have been unable to find a way to do this and was hoping that someone here would be able to help me in getting this completed. I am a novice at creating runbooks and currently have no real training on how to use Orchestrator.

System Center Orchestrator
System Center Orchestrator

A family of System Center products that provide an automation platform for orchestrating and integrating both Microsoft and non-Microsoft IT tools.

0 comments No comments

Answer accepted by question author
  1. Stefan Horz 3,551 Reputation points
    2021-08-31T21:13:28.953+00:00

    Hi @TBingeman ,
    one option is to redesign the Runbooks. One with "Monitor Date/Time" and the summary email. And the second one with "Read Line" to get the servers and the Activities which should be triggered for each server.
    Find the ois_export with the modifications here: https://1drv.ms/u/s!AkXRVOcQ_Bj_iNoQDAcR3X-Pi4zinQ
    Define the line for each result in the properties of the second Runbook and return it with "Return Data":

    128043-clearcache-2-doing.jpg

    Trigger this Runbook with the first Runbook and use "Flatten with line breaks" in the properties of the "Invoke Runbook" Activity.
    127990-clearcache-1-trigger.jpg

    Important is to check "Wait for Completion"!
    128055-clearcache-1-trigger-waitforcompletion.jpg

    In "Send EMail" subscribe the Result from "Invoke Runbook".

    Regards,
    Stefan


8 additional answers

Sort by: Most helpful
  1. Andreas Baumgarten 131.3K Reputation points MVP Volunteer Moderator
    2021-08-30T18:59:30.483+00:00

    Hi @TBingeman ,

    Just to get your requirements:
    You want to run the "Get Items" and "Delete Items" scripts in batches of 25 parallel/concurrently?
    You want the result of 1.2k script jobs in one email?

    If so, using 3 runbooks doesn't work.
    The second runbook will be executed for each server in the list (1.2 k servers?) and will trigger the third runbook 1.2k times = 1.2 k emails. That's the way Orchestrator works.

    In my opinion the only way it could work is with one runbook and redesigned scripts.

    I would merge the "Get Items" script with the "Delete Items" script and inside the PowerShell script using an option to run the PowerShell commands as jobs in parallel.
    Maybe this helps: https://devblogs.microsoft.com/powershell/powershell-foreach-object-parallel-feature/
    Every output will be written in the same text file -> 1.2k outputs in one text file
    Flattern the output of the script activity and send one email with the text file as an attachment after the script activity is done

    ----------

    (If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

    Regards
    Andreas Baumgarten


  2. TBingeman 81 Reputation points
    2021-08-30T15:24:17.957+00:00

    @Andreas Baumgarten ,

    The reason for the multiple runbooks in this process is to run the script against 25 machines concurrently instead of one after the other. This is why the email portion needs to be separated out so only 1 email is generated instead of 1 email for each server. This is the first time I am using Orchestrator and need to know how to set this up correctly to do what we need it to do.

    0 comments No comments

  3. Andreas Baumgarten 131.3K Reputation points MVP Volunteer Moderator
    2021-08-28T07:49:21.427+00:00

    Hi @TBingeman ,

    first question: Why are you using different Runbooks with just a few Activities (2 to 4 activites) in each Runbook? Is there a reason for this?
    May approach would be just using one Runbook.

    Some thoughts:

    • Create a shared folder for the log files on the Runbook server (if you have more than one Runbook Server)
    • in the Runbook:
    • Create a file in the shared folder with dynamic filename using date/time details (e.g. yyyyMMdd-HHmmss.txt / 20210828-115600-log.txt)
    • Modify your PowerShell scripts to write the required results/output in the created text file (Write-Host doesn't work in a Runbook, you could Write-Output instead)
    • Create an email and attach the text file stored in the shared folder (use the Run behavior "Flattern" in the options of the last .Net Script activity before the Send Mail activity. This should prevent to send more than one email) The Runbook could look like this (you could create the text file name in the first PowerShell script instead):

    127218-image.png


    (If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

    Regards
    Andreas Baumgarten

    0 comments No comments

  4. Andreas Baumgarten 131.3K Reputation points MVP Volunteer Moderator
    2021-08-27T18:25:56.2+00:00

    Hi @TBingeman ,

    one option is to write the output of all scripts in one text file (file-name for instance with a timestamp) in one shared folder (if you have more than one Runbook Server). After all scripts are done you have two options:

    • Attach the file to an email
    • Read the file content and put this in the email body

    ----------

    (If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

    Regards
    Andreas Baumgarten


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.