diff --git a/Modules/CIPPCore/Public/Entrypoints/Activity Triggers/Push-ExecScheduledCommand.ps1 b/Modules/CIPPCore/Public/Entrypoints/Activity Triggers/Push-ExecScheduledCommand.ps1 index 015589f57b06..4317db419974 100644 --- a/Modules/CIPPCore/Public/Entrypoints/Activity Triggers/Push-ExecScheduledCommand.ps1 +++ b/Modules/CIPPCore/Public/Entrypoints/Activity Triggers/Push-ExecScheduledCommand.ps1 @@ -26,14 +26,15 @@ function Push-ExecScheduledCommand { } try { - $ParamsToRemove = [System.Collections.Generic.List[string]]::new() - foreach ($Parameter in $commandParameters.GetEnumerator()) { - if (!$Function.Parameters.ContainsKey($Parameter.Key)) { - $ParamsToRemove.Add($Parameter.Key) + $PossibleParams = $Function.Parameters.Keys + $keysToRemove = [System.Collections.Generic.List[string]]@() + foreach ($key in $commandParameters.Keys) { + if (-not ($PossibleParams -contains $key)) { + $keysToRemove.Add($key) } } - foreach ($Param in $ParamsToRemove) { - $commandParameters.Remove($Param) + foreach ($key in $keysToRemove) { + $commandParameters.Remove($key) } } catch { Write-Host "Failed to remove parameters: $($_.Exception.Message)" diff --git a/version_latest.txt b/version_latest.txt index 77f5bec5b2b4..429dc57af3a3 100644 --- a/version_latest.txt +++ b/version_latest.txt @@ -1 +1 @@ -7.2.2 +7.2.3