Skip to content

Commit ae230e9

Browse files
committed
dynamic tenant group orchestrator
1 parent 10014b3 commit ae230e9

File tree

3 files changed

+62
-1
lines changed

3 files changed

+62
-1
lines changed

CIPPTimers.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,14 @@
105105
"Priority": 5,
106106
"RunOnProcessor": true
107107
},
108+
{
109+
"Id": "0967c860-3a57-4860-8f33-e5136eae7b4e",
110+
"Command": "Start-TenantDynamicGroupOrchestrator",
111+
"Description": "Orchestrator to update dynamic tenant groups",
112+
"Cron": "0 0 */4 * * *",
113+
"Priority": 6,
114+
"RunOnProcessor": true
115+
},
108116
{
109117
"Id": "4ca242d0-8dc8-4256-b0ed-186599f4233f",
110118
"Command": "Start-UpdateTokensTimer",
@@ -206,4 +214,4 @@
206214
"RunOnProcessor": true,
207215
"IsSystem": true
208216
}
209-
]
217+
]
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
function Push-UpdateDynamicTenantGroup {
2+
<#
3+
.SYNOPSIS
4+
Push an update to a Dynamic Tenant Group
5+
.FUNCTIONALITY
6+
Entrypoint
7+
#>
8+
9+
[CmdletBinding()]
10+
param ($Item)
11+
12+
Write-Information "Pushing update to Dynamic Tenant Group: $($Item.Name) (ID: $($Item.Id))"
13+
Update-CIPPDynamicTenantGroups -GroupId $Item.Id
14+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
function Start-TenantDynamicGroupOrchestrator {
2+
<#
3+
.SYNOPSIS
4+
Start the Tenant Dynamic Group Orchestrator
5+
6+
.FUNCTIONALITY
7+
Entrypoint
8+
#>
9+
[CmdletBinding(SupportsShouldProcess = $true)]
10+
param(
11+
[string]$GroupId = 'All'
12+
)
13+
14+
try {
15+
Write-Information 'Updating Dynamic Tenant Groups'
16+
$TenantGroups = @{
17+
Dynamic = $true
18+
}
19+
$TenantGroups = Get-TenantGroups @TenantGroups
20+
if ($GroupId -ne 'All') {
21+
$TenantGroups = $TenantGroups | Where-Object { $_.Id -eq $GroupId }
22+
}
23+
24+
if ($TenantGroups.Count -gt 0) {
25+
Write-Information "Found $($TenantGroups.Count) dynamic tenant groups"
26+
$Queue = New-CippQueueEntry -Name 'Dynamic Tenant Groups' -TotalTasks $TenantGroups.Count
27+
$TenantBatch = $TenantGroups | Select-Object Name, Id, @{n = 'FunctionName'; exp = { 'UpdateDynamicTenantGroup' } }, @{n = 'QueueId'; exp = { $Queue.RowKey } }
28+
$InputObject = [PSCustomObject]@{
29+
OrchestratorName = 'UpdateDynamicTenantGroups'
30+
Batch = @($TenantBatch)
31+
}
32+
if ($PSCmdlet.ShouldProcess('Start-TenantDynamicGroupOrchestrator', 'Starting Tenant Dynamic Group Orchestrator')) {
33+
Start-NewOrchestration -FunctionName 'CIPPOrchestrator' -InputObject ($InputObject | ConvertTo-Json -Depth 5 -Compress)
34+
}
35+
} else {
36+
Write-Information 'No tenants require permissions update'
37+
}
38+
} catch {}
39+
}

0 commit comments

Comments
 (0)