Skip to content

Commit 26d9582

Browse files
committed
fix scheduled command
1 parent 01e3722 commit 26d9582

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

Modules/CIPPCore/Public/Entrypoints/Activity Triggers/Push-ExecScheduledCommand.ps1

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,15 @@ function Push-ExecScheduledCommand {
2626
}
2727

2828
try {
29-
$ParamsToRemove = [System.Collections.Generic.List[string]]::new()
30-
foreach ($Parameter in $commandParameters.GetEnumerator()) {
31-
if (!$Function.Parameters.ContainsKey($Parameter.Key)) {
32-
$ParamsToRemove.Add($Parameter.Key)
29+
$PossibleParams = $Function.Parameters.Keys
30+
$keysToRemove = [System.Collections.Generic.List[string]]@()
31+
foreach ($key in $commandParameters.Keys) {
32+
if (-not ($PossibleParams -contains $key)) {
33+
$keysToRemove.Add($key)
3334
}
3435
}
35-
foreach ($Param in $ParamsToRemove) {
36-
$commandParameters.Remove($Param)
36+
foreach ($key in $keysToRemove) {
37+
$commandParameters.Remove($key)
3738
}
3839
} catch {
3940
Write-Host "Failed to remove parameters: $($_.Exception.Message)"

0 commit comments

Comments
 (0)