-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Expand file tree
/
Copy pathAdd-CippQueueMessage.ps1
More file actions
46 lines (42 loc) · 1.48 KB
/
Add-CippQueueMessage.ps1
File metadata and controls
46 lines (42 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
function Add-CippQueueMessage {
<#
.SYNOPSIS
Push a message to the Azure Storage Queue for background processing
.DESCRIPTION
Wraps Push-OutputBinding to send messages to the cippqueue for processing by CippQueueTrigger.
This offloads orchestration execution to the processor function app.
.PARAMETER Cmdlet
The name of the function to execute (must exist in CIPPCore module)
.PARAMETER Parameters
Hashtable of parameters to pass to the function
.EXAMPLE
Add-CippQueueMessage -Cmdlet 'Start-BPAOrchestrator' -Parameters @{ TenantFilter = 'AllTenants'; Force = $true }
.FUNCTIONALITY
Internal
#>
[CmdletBinding()]
param(
[Parameter(Mandatory = $true)]
[string]$Cmdlet,
[Parameter(Mandatory = $false)]
[hashtable]$Parameters = @{}
)
$QueueMessage = @{
Cmdlet = $Cmdlet
Parameters = $Parameters
}
try {
if ($env:CIPPNG -eq 'true') {
$ParametersJson = $Parameters | ConvertTo-Json -Depth 10 -Compress
[CRAFT.Services.QueueBridge]::Enqueue($Cmdlet, $ParametersJson)
Write-Information "CRAFT: Queued $Cmdlet for background execution"
return $true
}
Push-OutputBinding -Name QueueItem -Value $QueueMessage
Write-Information "Queued $Cmdlet for execution"
return $true
} catch {
Write-Error "Failed to queue message: $_"
return $false
}
}