Using runbooks is an easy and efficient way to run the GetMessagesToTeamsAndOutlook PowerShell script we’ve shared in previous posts. In Automating delivery of Message Center posts to Teams and Outlook using an Azure function, we share how to use an Azure function to run the script on a timer. In this post, we’ll use an Azure runbook to do the same thing.
Before you run this script using runbooks you’ll want to follow directions in the following posts to get values to put into the script above.
Using O365 APIs and PowerShell to access Intune messages from Message center in Office 365: This post outlines how to create an AzureAD application.
Automating delivery of Message Center posts to Teams and Outlook using an Azure function: Here you will find directions to get Webhook URIs for Teams and Outlook.
After you’re done setting this up, you can set up an Azure Automation account, create an Azure runbook, and automate the process using the steps below.
The first step is to ensure you have an Azure subscription. Then create an Azure Automation account. To do this, follow the steps here: Create Automation account
In your Automation account, go to Shared Resources > Modules to ensure you have an AzureAD module in the list of available modules. If you don't see it available, click on Browse gallery, search for Azure AD and click Import.
Next create a PowerShell runbook using the instructions here: My first PowerShell runbook
You can find your created runbook under Process Automation in your Automation account. Click on your runbook. At the top of the page, go to Schedule > Create a new schedule.
Set up the schedule you want and link to your runbook. Make sure your Parameters and Run settings under Schedule are set to Run on Azure.
In your runbook, click Edit. Paste your PowerShell script in here and input Azure application details and webhook URIs. You can change Write-Host in the script to Write-Output if you want to see the results in the output window of the runbook.
Don’t forget to go back to your runbook and press Start. Your messages will now be delivered to the platforms you’ve chosen on the schedule you’ve configured in your runbook.