You need to pass the function itself (not a call to the function in the ScriptBlock
).
I had the same need just last week and found this SO discussion
So your code will become:
Invoke-Command -ScriptBlock ${function:foo} -argumentlist "Bye!" -ComputerName someserver.example.com -Credential [email protected]
Note that by using this method, you can only pass parameters into your function positionally; you can’t make use of named parameters as you could when running the function locally.