Skip to content

Commit a292ead

Browse files
committed
fix issue with activity function returning $true
Only return $true when no output is detected
1 parent 1de164f commit a292ead

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

Modules/CippEntrypoints/CippEntrypoints.psm1

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,9 @@ function Receive-CippOrchestrationTrigger {
133133
}
134134

135135
if (!$OrchestratorInput.Batch -or ($OrchestratorInput.Batch | Measure-Object).Count -eq 0) {
136-
$Batch = (Invoke-ActivityFunction -FunctionName 'CIPPActivityFunction' -Input $OrchestratorInput.QueueFunction -ErrorAction Stop)
136+
$Batch = @(Invoke-ActivityFunction -FunctionName 'CIPPActivityFunction' -Input $OrchestratorInput.QueueFunction -ErrorAction Stop)
137137
} else {
138-
$Batch = $OrchestratorInput.Batch
138+
$Batch = @($OrchestratorInput.Batch)
139139
}
140140

141141
if (($Batch | Measure-Object).Count -gt 0) {
@@ -179,6 +179,7 @@ function Receive-CippActivityTrigger {
179179
Write-Warning "Hey Boo, the activity function is running. Here's some info: $($Item | ConvertTo-Json -Depth 10 -Compress)"
180180
try {
181181
$Start = Get-Date
182+
$Output = $null
182183
Set-Location (Get-Item $PSScriptRoot).Parent.Parent.FullName
183184

184185
if ($Item.QueueId) {
@@ -202,7 +203,7 @@ function Receive-CippActivityTrigger {
202203
$FunctionName = 'Push-{0}' -f $Item.FunctionName
203204
try {
204205
Write-Warning "Activity starting Function: $FunctionName."
205-
Invoke-Command -ScriptBlock { & $FunctionName -Item $Item }
206+
$Output = Invoke-Command -ScriptBlock { & $FunctionName -Item $Item }
206207
Write-Warning "Activity completed Function: $FunctionName."
207208
if ($TaskStatus) {
208209
$QueueTask.Status = 'Completed'
@@ -244,7 +245,13 @@ function Receive-CippActivityTrigger {
244245
$null = Set-CippQueueTask @QueueTask
245246
}
246247
}
247-
return $true
248+
249+
# Return the captured output if it exists and is not null, otherwise return $true
250+
if ($null -ne $Output -and $Output -ne '') {
251+
return $Output
252+
} else {
253+
return $true
254+
}
248255
}
249256

250257
function Receive-CIPPTimerTrigger {

0 commit comments

Comments
 (0)