Home Retrieve Message Centre announcements and post to MS Teams channel
Post
Cancel

Retrieve Message Centre announcements and post to MS Teams channel

Summary

This script allows you to connect to your SharePoint Online tenant and retrieve Message Centre announcements. It then connects to Microsoft Teams and loops through the announcements, posting them to a specific Teams channel.

Messages

Implementation

  1. Create csv file with the list of site collection URLs to enable app catalog
  2. Open Windows PowerShell ISE
  3. Create a new file
  4. Copy the code below
  5. Save the file and run it

Pnp PowerShell

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# Connect to SharePoint Online

Connect-PnPOnline -Url https://yourTenantName.sharepoint.com/ -Interactive 

# Get Message Centre announcements
$announcements = Get-PnPMessageCenterAnnouncement | Where-Object { $_.Category -eq "PlanForChange" } | Select-Object Title, Description

# Connect to teams
Connect-MicrosoftTeams 

# Loop through the announcements and post to Teams channel
foreach ($announcement in $announcements) {
    $message = "$($announcement.Title): $($announcement.Description)"
    Submit-PnPTeamsChannelMessage -Team "TeamID" -Channel "General" -Message $message
}

PNP Script sample site

Script sample site

This post is licensed under CC BY 4.0 by the author.

Tip Of The Day. SPFx Localization extension

Tip of the day. Respnsive grid using CSS