Skip to content

Commit 1e300e4

Browse files
committed
tweak scheduled tasks
1 parent 359ea31 commit 1e300e4

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

Modules/CIPPCore/Public/Add-CIPPScheduledTask.ps1

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,17 +99,17 @@ function Add-CIPPScheduledTask {
9999
$excludedTenants = if ($task.excludedTenants.value) {
100100
$task.excludedTenants.value -join ','
101101
}
102-
102+
103103
# Handle tenant filter - support both single tenant and tenant groups
104104
$tenantFilter = $task.TenantFilter.value ? $task.TenantFilter.value : $task.TenantFilter
105105
$originalTenantFilter = $task.TenantFilter
106-
106+
107107
# If tenant filter is a complex object (from form), extract the value
108108
if ($tenantFilter -is [PSCustomObject] -and $tenantFilter.value) {
109109
$originalTenantFilter = $tenantFilter
110110
$tenantFilter = $tenantFilter.value
111111
}
112-
112+
113113
# If tenant filter is a string but still seems to be JSON, try to parse it
114114
if ($tenantFilter -is [string] -and $tenantFilter.StartsWith('{')) {
115115
try {
@@ -123,7 +123,7 @@ function Add-CIPPScheduledTask {
123123
Write-Warning "Could not parse tenant filter JSON: $tenantFilter"
124124
}
125125
}
126-
126+
127127
$entity = @{
128128
PartitionKey = [string]'ScheduledTask'
129129
TaskState = [string]'Planned'
@@ -140,7 +140,7 @@ function Add-CIPPScheduledTask {
140140
Hidden = [bool]$Hidden
141141
Results = 'Planned'
142142
}
143-
143+
144144
# Store the original tenant filter for group expansion during execution
145145
if ($originalTenantFilter -is [PSCustomObject] -and $originalTenantFilter.type -eq 'Group') {
146146
$entity['TenantGroup'] = [string]($originalTenantFilter | ConvertTo-Json -Compress)

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Scheduler/Invoke-ListScheduledItemDetails.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ function Invoke-ListScheduledItemDetails {
6666
$TenantGroupForDisplay = [PSCustomObject]@{
6767
label = $TenantGroupObject.label
6868
value = $TenantGroupObject.value
69-
type = 'Group'
69+
type = 'Group'
7070
}
7171
$Task | Add-Member -NotePropertyName TenantGroupInfo -NotePropertyValue $TenantGroupForDisplay -Force
7272
# Update the tenant to show the group object for proper formatting
@@ -81,7 +81,7 @@ function Invoke-ListScheduledItemDetails {
8181
$TenantForDisplay = [PSCustomObject]@{
8282
label = $Task.Tenant
8383
value = $Task.Tenant
84-
type = 'Tenant'
84+
type = 'Tenant'
8585
}
8686
$Task.Tenant = $TenantForDisplay
8787
}

Modules/CIPPCore/Public/Entrypoints/Orchestrator Functions/Start-UserTasksOrchestrator.ps1

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,20 +55,20 @@ function Start-UserTasksOrchestrator {
5555
try {
5656
$TenantGroupObject = $task.TenantGroup | ConvertFrom-Json
5757
Write-Host "Expanding tenant group: $($TenantGroupObject.label) with ID: $($TenantGroupObject.value)"
58-
58+
5959
# Create a tenant filter object for expansion
6060
$TenantFilterForExpansion = @([PSCustomObject]@{
61-
type = 'Group'
62-
value = $TenantGroupObject.value
63-
label = $TenantGroupObject.label
64-
})
65-
61+
type = 'Group'
62+
value = $TenantGroupObject.value
63+
label = $TenantGroupObject.label
64+
})
65+
6666
# Expand the tenant group to individual tenants
6767
$ExpandedTenants = Expand-CIPPTenantGroups -TenantFilter $TenantFilterForExpansion
68-
68+
6969
$ExcludedTenants = $task.excludedTenants -split ','
7070
Write-Host "Excluded Tenants from this task: $ExcludedTenants"
71-
71+
7272
$GroupTenantCommands = foreach ($ExpandedTenant in $ExpandedTenants | Where-Object { $_.value -notin $ExcludedTenants }) {
7373
$NewParams = $task.Parameters.Clone()
7474
if ((Get-Command $task.Command).Parameters.TenantFilter) {
@@ -85,7 +85,7 @@ function Start-UserTasksOrchestrator {
8585
} catch {
8686
Write-Host "Error expanding tenant group: $($_.Exception.Message)"
8787
Write-LogMessage -API 'Scheduler_UserTasks' -tenant $tenant -message "Failed to expand tenant group for task $($task.Name): $($_.Exception.Message)" -sev Error
88-
88+
8989
# Fall back to treating as single tenant
9090
if ((Get-Command $task.Command).Parameters.TenantFilter) {
9191
$ScheduledCommand.Parameters['TenantFilter'] = $task.Tenant

0 commit comments

Comments
 (0)