Skip to content

Instantly share code, notes, and snippets.

@MatthewJDavis
Created July 30, 2018 00:43
Show Gist options
  • Select an option

  • Save MatthewJDavis/4598eef65dfb370fb0e1d2306fe03d4d to your computer and use it in GitHub Desktop.

Select an option

Save MatthewJDavis/4598eef65dfb370fb0e1d2306fe03d4d to your computer and use it in GitHub Desktop.
PowerShell runbook for Azure automation webhook example
<#
Script to demo how to get data from a posted webhook
#>
Param
(
[object]$WebhookData
)
if ($WebhookData) {
# If section for testing providing webhook data via the Azure portal
if (-Not $WebhookData.RequestBody) {
Write-Output 'No request body from test pane'
$WebhookData = (ConvertFrom-JSON -InputObject $WebhookData)
Write-Output "WebhookData = $WebhookData"
$data = (ConvertFrom-JSON -InputObject $WebhookData.RequestBody)
Write-Output "Service = $($data.Service)"
Write-Output "Host = $($data.Host)"
Return
}
$request = (ConvertFrom-JSON -InputObject $WebhookData.RequestBody)
$data = (ConvertFrom-JSON -InputObject $request.RequestBody)
Write-Output "Service = $($data.Service)"
Write-Output "Host = $($data.Host)"
}
Else {
Write-Output 'No data received'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment