diff --git a/Modules/CIPPCore/Public/Entrypoints/Activity Triggers/Push-ExecScheduledCommand.ps1 b/Modules/CIPPCore/Public/Entrypoints/Activity Triggers/Push-ExecScheduledCommand.ps1 index 65ce3ff5d36a..3f1c9dacb6b8 100644 --- a/Modules/CIPPCore/Public/Entrypoints/Activity Triggers/Push-ExecScheduledCommand.ps1 +++ b/Modules/CIPPCore/Public/Entrypoints/Activity Triggers/Push-ExecScheduledCommand.ps1 @@ -11,7 +11,7 @@ function Push-ExecScheduledCommand { $task = $Item.TaskInfo $commandParameters = $Item.Parameters | ConvertTo-Json -Depth 10 | ConvertFrom-Json -AsHashtable - $tenant = $Item.Parameters['TenantFilter'] + $tenant = $Item.Parameters.TenantFilter Write-Host "Started Task: $($Item.Command) for tenant: $tenant" try { try { diff --git a/Scheduler_UserTasks/run.ps1 b/Scheduler_UserTasks/run.ps1 index 950ca9e691bb..27b975443797 100644 --- a/Scheduler_UserTasks/run.ps1 +++ b/Scheduler_UserTasks/run.ps1 @@ -4,6 +4,7 @@ $Table = Get-CippTable -tablename 'ScheduledTasks' $Filter = "TaskState eq 'Planned' or TaskState eq 'Failed - Planned'" $tasks = Get-CIPPAzDataTableEntity @Table -Filter $Filter $Batch = [System.Collections.Generic.List[object]]::new() +$TenantList = Get-Tenants -IncludeErrors foreach ($task in $tasks) { $tenant = $task.Tenant $currentUnixTime = [int64](([datetime]::UtcNow) - (Get-Date '1/1/1970')).TotalSeconds @@ -27,7 +28,7 @@ foreach ($task in $tasks) { } if ($task.Tenant -eq 'AllTenants') { - $AllTenantCommands = foreach ($Tenant in Get-Tenants) { + $AllTenantCommands = foreach ($Tenant in $TenantList) { $NewParams = $task.Parameters.Clone() $NewParams.TenantFilter = $Tenant.defaultDomainName [pscustomobject]@{