Parameters in calls to functions in PowerShell (all versions) are space-separated, not comma-separated. Also, the parentheses are entirely unnecessary and will cause a parse error in PowerShell 2.0 (or later) if Set-StrictMode -Version 2 or higher is active. Parenthesised arguments are used in .NET methods only.
function foo(
b, $c) {
"a:
b; c: $c"
}
Execute:
foo 1 2 3
Output:
a: 1; b: 2; c: 3
Answer from x0n on Stack Overflowsyntax - How do I pass multiple parameters into a function in PowerShell? - Stack Overflow
What’s in your Powershell profile
metadata - Powershell functions defined in profile - Stack Overflow
How can I set an alias with default parameters for a command in powershell?
Videos
Parameters in calls to functions in PowerShell (all versions) are space-separated, not comma-separated. Also, the parentheses are entirely unnecessary and will cause a parse error in PowerShell 2.0 (or later) if Set-StrictMode -Version 2 or higher is active. Parenthesised arguments are used in .NET methods only.
function foo(
b, $c) {
"a:
b; c: $c"
}
Execute:
foo 1 2 3
Output:
a: 1; b: 2; c: 3
The correct answer has already been provided, but this issue seems prevalent enough to warrant some additional details for those wanting to understand the subtleties.
I would have added this just as a comment, but I wanted to include an illustration—I tore this off my quick reference chart on PowerShell functions. This assumes function f's signature is f(:b, $c)

Thus, one can call a function with space-separated positional parameters or order-independent named parameters. The other pitfalls reveal that you need to be cognizant of commas, parentheses, and white space.
For further reading, see my article Down the Rabbit Hole: A Study in PowerShell Pipelines, Functions, and Parameters. The article contains a link to the quick reference/wall chart as well.
Hi All,
I’ve recently been adding some helpful functions into my Powershell profile to help with some daily tasks and general helpfulness. I have things like a random password string generator, pomodoro timer, Zulu date checker etc to name a few.
What are some things everyone else has in their profile ?
If I'm understanding what you're looking to do, then yes, totally doable.
Wrap your foobar.exe call in quotes to make it all a single string.
"foobar.exe -param1 -param2"
In your function, put cmd /c before the string. https://stackoverflow.com/questions/515309/what-does-cmd-c-mean
Then, use Set-Alias to set it how you like, with -Value as the function name.
All together...
function doSomething() {
cmd /c "foobar.exe -param1 -param2"
}
Set-Alias -Name FOOBAR -Value doSomething
Now, when FOOBAR is ran in PS, it executes foobar.exe -param1 -param2 as if you typed it manually.
If I misunderstood the question, please let me know. Hopefully this helps.
With the very same PSVersion I get different results:
PoSh> function FB {pathto/foobar.exe -parameter1 %%(option1)s.%%(option1a)s -parameter2 --option2}
PoSh> (Get-Command FB).Definition
pathto/foobar.exe -parameter1 %%(option1)s.%%(option1a)s -parameter2 --option2
PoSh> Set-Alias FOOBAR -Value FB
PoSh> Get-Alias FOOBAR
CommandType Name Version Source
----------- ---- ------- ------
Alias FOOBAR -> FB
So it's neither the definition of the function (whose script block is evaluated on execution) nor the definition of the Alias what provokes the error you describe.
It's more likely the error is about quoting, wrong parentheses or arguments at the time the script block is executed.