How would you like this lovely notification appearing within MS Teams every time a build failed? Better than getting a helpdesk ticket or not finding out at all.
Well, now you can!
Removed broken screenshot - editor
Step 1 - Configure Teams
You need to make sure your O365 Administrator has enabled Incoming webhooks connectors in your O365 Tenant.
- Open Teams.
- Select a channel, or create a new channel specific for these notifications (This is best practice so normal channels are not spammed)
- Click the … Next to the channel name and choose Connectors
Removed broken screenshot - editor
- Click Add / Configure
Removed broken screenshot - editor
- Give your Connector an appropriate name and custom image.
Removed broken screenshot - editor
- It will then generate a unique API code for you to use later. Copy this URI and keep it safe!
Removed broken screenshot - editor
Step 2 - PowerShell Script
I have modified the PowerShell script created by Terence Beggs from https://www.scconfigmgr.com/2017/10/06/configmgr-osd-notification-service-teams/
|
|
Customizing the MessageCard
If you want to change the JSON, there is a reference guide here: https://docs.microsoft.com/en-us/outlook/actionable-messages/message-card-reference
And a Playground site: https://messagecardplayground.azurewebsites.net/
This modification of the PowerShell script means you can just copy/paste the JSON as long as it’s wrapped inside $body = @" … “@
NB: Incoming Webconnectors only support the Legacy MessageCard format at this time.
Step 3 - Create Package for Script
- Copy the PowerShell script to your Config Manager package source share.
- In Config Manager Console, create a new Package.
- Give it a Name, Description, and specify the source share
Removed broken screenshot - editor
- Select Do not create a program
Removed broken screenshot - editor
- Complete the wizard.
- Distribute the Package contents.
Step 4 - Task Sequence
Edit the task sequence for OSD.
Our TS is set up with logic and a section to run if the task sequence encounters an error. This is where we will put the OSD Failure notification script.
For more information on how to set up Error Handling in OSD Task Sequence, see Jörgen Nilsson’s post about it here: https://ccmexec.com/2016/12/error-handling-in-ts-without-mdt-using-osdbackground/
Removed broken screenshot - editor
- After the Gather step, we want to add a Run PowerShell Script task.
- Select the package with our Script.
- Change the PowerShell execution policy to Bypass
Removed broken screenshot - editor
- Click OK and that’s it set up!
If you want to try emulating a failure, create a Run Command Line task somewhere in your Task Sequence that runs the following:
cmd /c exit 8008135
Removed broken screenshot - editor
So now, if your task sequence runs into an error, you will now get a lovely message straight into your Teams channel:
Removed broken screenshot - editor
Grant Dickins Contributor
Grant has worked supporting IT in the Oil & Gas industry for 10 years, has a keen interest in Config Manager and trying to bring the industry kicking and screaming into the modern cloud-based world.