I experience some problem with executing PowerShell
command from CMD
.
I have a function MyFunction
in PowerShell which takes two parameters: Id
and Text
.
Example:
MyFunction 12345 "Name = Karl"
I need to call this function from CMD
:
powershell -Command . { MyFunction $* }
where $*
: 12345 "Name = Karl"
But I get error:
A positional parameter cannot be found that accepts argument 'Karl'
The cause of it is quotes are being removed from passing parameters
I figured out I need to escape all quotes in passing parameters but I really don't know how to do it within $*
. I'm not expert in CMD
, could you please help me to solve the issue?
Update (12/25/2019)
I forgot to mention I'm creating an alias via doskey
and I don't know how to escaping quotes within $*
MyFunction=powershell -Command . { MyFunction $* }