@@ -28,7 +28,7 @@ function Invoke-ListScheduledItemDetails {
2828
2929 # Retrieve the task information
3030 $TaskTable = Get-CIPPTable - TableName ' ScheduledTasks'
31- $Task = Get-CIPPAzDataTableEntity @TaskTable - Filter " RowKey eq '$RowKey ' and PartitionKey eq 'ScheduledTask'" | Select-Object Name, TaskState, Command, Parameters, Recurrence, ExecutedTime, ScheduledTime, PostExecution, Tenant, Hidden , Results, Timestamp
31+ $Task = Get-CIPPAzDataTableEntity @TaskTable - Filter " RowKey eq '$RowKey ' and PartitionKey eq 'ScheduledTask'" | Select-Object Name, TaskState, Command, Parameters, Recurrence, ExecutedTime, ScheduledTime, PostExecution, Tenant, TenantGroup , Hidden , Results, Timestamp
3232
3333 if (-not $Task ) {
3434 Push-OutputBinding - Name Response - Value ([HttpResponseContext ]@ {
@@ -57,6 +57,35 @@ function Invoke-ListScheduledItemDetails {
5757 $Task.ScheduledTime = [DateTimeOffset ]::FromUnixTimeSeconds($Task.ScheduledTime ).UtcDateTime
5858 } catch {}
5959
60+ # Handle tenant group display information (similar to Invoke-ListScheduledItems)
61+ if ($Task.TenantGroup ) {
62+ try {
63+ $TenantGroupObject = $Task.TenantGroup | ConvertFrom-Json - ErrorAction SilentlyContinue
64+ if ($TenantGroupObject ) {
65+ # Create a tenant group object for the frontend formatting
66+ $TenantGroupForDisplay = [PSCustomObject ]@ {
67+ label = $TenantGroupObject.label
68+ value = $TenantGroupObject.value
69+ type = ' Group'
70+ }
71+ $Task | Add-Member - NotePropertyName TenantGroupInfo - NotePropertyValue $TenantGroupForDisplay - Force
72+ # Update the tenant to show the group object for proper formatting
73+ $Task.Tenant = $TenantGroupForDisplay
74+ }
75+ } catch {
76+ Write-Warning " Failed to parse tenant group information for task $ ( $Task.RowKey ) : $ ( $_.Exception.Message ) "
77+ # Fall back to keeping original tenant value
78+ }
79+ } else {
80+ # For regular tenants, create a tenant object for consistent formatting
81+ $TenantForDisplay = [PSCustomObject ]@ {
82+ label = $Task.Tenant
83+ value = $Task.Tenant
84+ type = ' Tenant'
85+ }
86+ $Task.Tenant = $TenantForDisplay
87+ }
88+
6089 # Get the results if available
6190 $ResultsTable = Get-CIPPTable - TableName ' ScheduledTaskResults'
6291 $ResultsFilter = " PartitionKey eq '$RowKey '"
0 commit comments