Post log from script in MS Teams Channel

Log execution steps from scripts in Microsoft Teams Channel

It is possible to notify users about the execution of a script through a message in an MS Teams channel. The progress or the result of a script can be logged with the function SendMessage2Channel from the MSTLibrary script library (via GitHub).

This script is part of the ScriptRunner Action Pack MS Teams

Before the function can be used, a connector of the type Incoming Webhook must be configured for the target channel in MS Teams.

  • Define the library script in the Action Wizard.
    Select the action and click the EDIT button in the Action Bar (below). Then select the Wizard page PowerShell Options. After activating Library script to preload..., the library script can be selected. The library script will be listed in the drop-down list, if it is stored in a script repository folder named _LIB_ or marked with the _LIB_ tag. Now you can call the SendMessage2Channel function.
  • These parameters are required:

    • WebhookURL
      The URL of the Webhook, it must match with "https://outlook.office.com/webhook/"
    • Message
      The body of the message to publish on Teams channel
  • Optionally these parameters can be set:
    • Title
      The title of the message to publish on Teams
    • MessageColor
      The color theme for the message. Orange, green or red
    • ActivityTitle
      The Activity title of the message
    • ActivitySubtitle
      The Activity subtitle of the message to publish
    • ActivityFacts
    • Hashtable-array
      Each hashtable is only allowed to contain one element, and is one line!
      Example:
      [hashtable[]]$multiline = @()
      $multiline += @{'one','line 1'}
      $multiline += @{'two','line 2'}
      ...
       

      The library script can be found here: ScriptRunner MS Teams Action Pack

      This page has been automatically translated and may contain grammatical errors or inaccuracies