#https://96bdfe01-af80-4575-8f23-e7057184c8f6.webhook.cus.azure-automation.net/webhooks?token=4cWZz%2fq97AqMdlNak6qv2lUurLPFsWmPJmovLmAE%2fNg%3d
[CmdletBinding()]
param
(
    [Parameter(Mandatory = $false)]
    [object] $WebhookData
)

If ($WebhookData) {
    If ($WebhookData.RequestHeader.ITD -eq 'mXJU74ABYyDHcVY6iJihPDk8LidJ2ibBA2sA3RAwKaBHS6Gw7Rr2Zz5JZAhPm6wMuvY7X54ZzJxAXaM7ig3PHG4MKvtkBf8X7q3jGNcePgUqg9WCwCSJ3JWG7AA6M39x4vpihKeZV') {
        Write-Verbose "Header has required data"
        Write-Host $
    }
    Else {
        Write-Error "Header missing required data"
        exit;
    }

    $InputParams = (ConvertFrom-Json -InputObject $WebhookData.RequestBody)
    $ComputerName = $InputParams.target_hostname.ToLower()
    $TimeStamp = Get-Date -UFormat "%Y%m%d%H%M%S"
    $InputParams | Export-Csv "E:\AutoBuildInputFiles\$ComputerName-$Timestamp.csv"
}