AzureAutomationRunbook.ps1
param ( [Parameter(Mandatory=$false)] [object]$WebhookData ) if ($WebhookData -ne $null) { # Extract the webhook request body (payload) $WebhookBody = $WebhookData.RequestBody | ConvertFrom-Json $APIKeyRequest = $WebhookBody.APIKey $Firstname = $WebhookBody.Firstname $Lastname = $WebhookBody.Lastname $APIKeyStored = Get-AutomationVariable -Name "APIKey" If (!($APIKeyRequest -eq $APIKeyStored)) { Write-Output "401: Unauthorized. Unknown API Key." throw "401: Unauthorized. Unknown API Key." } else { Write-Output "200: Successful authentication." } } else { Write-Output "WebhookData is null. No payload was received." } $PathToMappingFile = Get-AutomationVariable -Name "PathToMappingFile" $PathToCsv = Get-AutomationVariable -Name "PathToCsv" $OutputCSVPath = Get-AutomationVariable -Name "OutputCSVPath" $APIProv_APIAppServicePrincipalId = Get-AutomationVariable -Name "APIProv_APIAppServicePrincipalId" $APIProv_AzureAppRegistrationClientId = Get-AutomationVariable -Name "APIProv_AzureAppRegistrationClientId" $APIProv_CertificateThumbprint = Get-AutomationVariable -Name "APIProv_CertificateThumbprint" $tenantId = Get-AutomationVariable -Name "tenantId" Write-Output "Done reading config." Write-Output "----------------------------------------------------------------" Test-Path $PathToMappingFile Test-Path $OutputCSVPath New-YcIAMCsvFromMapping -AttributeMappingFilePath $PathToMappingFile -OutputCSVPath $OutputCSVPath #Add-YcIAMRowToImportCSV -csvPath $OutputCSVPath -Firstname $Firstname -LastName $lastname |