Skip to content

Commit

Permalink
add support for api driven tasks which come in as json.
Browse files Browse the repository at this point in the history
  • Loading branch information
KelvinTegelaar committed Jul 12, 2024
1 parent e14f350 commit b7cba81
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Modules/CIPPCore/Public/Add-CIPPScheduledTask.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@ function Add-CIPPScheduledTask {
$propertiesToCheck = @('Webhook', 'Email', 'PSA')
$PostExecution = ($propertiesToCheck | Where-Object { $task.PostExecution.$_ -eq $true }) -join ','
$Parameters = [System.Collections.Hashtable]@{}
foreach ($Key in $task.Parameters.Keys) {
foreach ($Key in $task.Parameters.PSObject.Properties.Name) {
$Param = $task.Parameters.$Key
if ($Param.Key) {
if ($Param -is [System.Collections.IDictionary]) {
$ht = @{}
foreach ($p in $Param) {
Write-Host $p.Key
foreach ($p in $Param.GetEnumerator()) {
$ht[$p.Key] = $p.Value
}
$Parameters[$Key] = [PSCustomObject]$ht
} else {
$Parameters[$Key] = $Param
}
}

$Parameters = ($Parameters | ConvertTo-Json -Depth 10 -Compress)
$AdditionalProperties = [System.Collections.Hashtable]@{}
foreach ($Prop in $task.AdditionalProperties) {
Expand Down

0 comments on commit b7cba81

Please sign in to comment.