Skip to content

Commit b7cba81

Browse files
add support for api driven tasks which come in as json.
1 parent e14f350 commit b7cba81

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

Modules/CIPPCore/Public/Add-CIPPScheduledTask.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,19 @@ function Add-CIPPScheduledTask {
1919
$propertiesToCheck = @('Webhook', 'Email', 'PSA')
2020
$PostExecution = ($propertiesToCheck | Where-Object { $task.PostExecution.$_ -eq $true }) -join ','
2121
$Parameters = [System.Collections.Hashtable]@{}
22-
foreach ($Key in $task.Parameters.Keys) {
22+
foreach ($Key in $task.Parameters.PSObject.Properties.Name) {
2323
$Param = $task.Parameters.$Key
24-
if ($Param.Key) {
24+
if ($Param -is [System.Collections.IDictionary]) {
2525
$ht = @{}
26-
foreach ($p in $Param) {
27-
Write-Host $p.Key
26+
foreach ($p in $Param.GetEnumerator()) {
2827
$ht[$p.Key] = $p.Value
2928
}
3029
$Parameters[$Key] = [PSCustomObject]$ht
3130
} else {
3231
$Parameters[$Key] = $Param
3332
}
3433
}
34+
3535
$Parameters = ($Parameters | ConvertTo-Json -Depth 10 -Compress)
3636
$AdditionalProperties = [System.Collections.Hashtable]@{}
3737
foreach ($Prop in $task.AdditionalProperties) {

0 commit comments

Comments
 (0)