diff --git a/StackMonkey.ps1 b/StackMonkey.ps1 index dff4382..143d572 100644 --- a/StackMonkey.ps1 +++ b/StackMonkey.ps1 @@ -1572,7 +1572,25 @@ $script Invoke-ScriptMonkey @PSBoundParameters } else { # iwr | iex fallback - Invoke-ScriptMonkey + if ($args.Count -gt 0) { + # Convert -Param value -Switch into a hashtable for splatting + $namedArgs = @{} + for ($i = 0; $i -lt $args.Count; $i++) { + if ($args[$i] -is [string] -and $args[$i].StartsWith('-')) { + $key = $args[$i].TrimStart('-') + $next = $args[$i + 1] + if ($next -and ($next -notlike '-*')) { + $namedArgs[$key] = $next + $i++ # Skip next one, it's the value + } else { + $namedArgs[$key] = $true + } + } + } + Invoke-ScriptMonkey @namedArgs + } else { + Invoke-ScriptMonkey + } }