SCCM Teams Notification Task

Type: Run PowerShell Script

Name: Send Teams Failed Notice

Description: Send Teams Notice

Enter a PowerShell script:

Param(
[string]$ComputerName = $env:COMPUTERNAME,
[string]$ErrorTask,
[string]$ErrorCode,
[string]$WebHook
)

$body = '{"@type":"MessageCard","@context":"http://schema.org/extensions","themeColor":"d70700","summary":"Build Failed","sections":[{"activityTitle":"Microsoft Endpoint Configuration Manager","activitySubtitle":"Build Failed","facts":[{"name":"Hostname","value":"' + $ComputerName + '"},{"name":"Failed Task","value":"' + $ErrorTask + '"},{"name":"Error Code","value":"' + $ErrorCode + '"}],"markdown": true}]}'

Invoke-RestMethod -UseBasicParsing -Uri $WebHook -Method Post -Body $body -ContentType 'application/json'

Parameters:

-ComputerName "%OSDComputerName%" -ErrorTask '%ERRORTASK%' -ErrorCode '%ERRORCODE%' -WebHook '%TEAMSWEBHOOK%'

Document Actions