Skip to content

Commit 623bfe1

Browse files
authored
Merge pull request #446 from KelvinTegelaar/dev
[pull] dev from KelvinTegelaar:dev
2 parents 773baba + d2c8357 commit 623bfe1

File tree

3 files changed

+59
-3
lines changed

3 files changed

+59
-3
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
using namespace System.Net
2+
3+
function Invoke-ExecSetPackageTag {
4+
<#
5+
.FUNCTIONALITY
6+
Entrypoint,AnyTenant
7+
.ROLE
8+
CIPP.Core.ReadWrite
9+
#>
10+
[CmdletBinding()]
11+
param($Request, $TriggerMetadata)
12+
13+
$APIName = $Request.Params.CIPPEndpoint
14+
$Headers = $Request.Headers
15+
Write-LogMessage -headers $Headers -API $APIName -message 'Accessed this API' -Sev 'Debug'
16+
$Table = Get-CippTable -tablename 'templates'
17+
18+
try {
19+
$GUIDS = $Request.body.GUID
20+
$PackageName = $Request.body.Package | Select-Object -First 1
21+
foreach ($GUID in $GUIDS) {
22+
$Filter = "RowKey eq '$GUID'"
23+
$Template = Get-CIPPAzDataTableEntity @Table -Filter $Filter
24+
Add-CIPPAzDataTableEntity @Table -Entity @{
25+
JSON = $Template.JSON
26+
RowKey = "$GUID"
27+
PartitionKey = $Template.PartitionKey
28+
GUID = "$GUID"
29+
Package = "$PackageName"
30+
} -Force
31+
32+
Write-LogMessage -headers $Headers -API $APIName -message "Successfully updated template with GUID $GUID with package tag: $PackageName" -Sev 'Info'
33+
}
34+
35+
$body = [pscustomobject]@{ 'Results' = "Successfully updated template(s) with package tag: $PackageName" }
36+
37+
} catch {
38+
$ErrorMessage = Get-CippException -Exception $_
39+
Write-LogMessage -headers $Headers -API $APIName -message "Failed to set package tag: $($ErrorMessage.NormalizedError)" -Sev 'Error' -LogData $ErrorMessage
40+
$body = [pscustomobject]@{'Results' = "Failed to set package tag: $($ErrorMessage.NormalizedError)" }
41+
}
42+
43+
# Associate values to output bindings by calling 'Push-OutputBinding'.
44+
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
45+
StatusCode = [HttpStatusCode]::OK
46+
Body = $body
47+
})
48+
}

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Endpoint/MEM/Invoke-ListIntuneTemplates.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using namespace System.Net
22

3-
Function Invoke-ListIntuneTemplates {
3+
function Invoke-ListIntuneTemplates {
44
<#
55
.FUNCTIONALITY
66
Entrypoint,AnyTenant
@@ -45,6 +45,7 @@ Function Invoke-ListIntuneTemplates {
4545
$data | Add-Member -NotePropertyName 'description' -NotePropertyValue $JSONData.Description -Force
4646
$data | Add-Member -NotePropertyName 'Type' -NotePropertyValue $JSONData.Type -Force
4747
$data | Add-Member -NotePropertyName 'GUID' -NotePropertyValue $_.RowKey -Force
48+
$data | Add-Member -NotePropertyName 'package' -NotePropertyValue $_.Package -Force
4849
$data
4950
} catch {
5051

Modules/CippEntrypoints/CippEntrypoints.psm1

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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)