Question:
Can someone explain the differences between Invoke-Expression $test
and Invoke-Expression -Command $test
?
variable test is:
1 2 |
$test = "notepad.exe myfile.txt" |
Answer:
Both Invoke-Expression $test
and Invoke-Expression -Command $test
are the same. Both will put $test
into the ‘command’ parameter that is at position 1. The -Command
is and optional parameter name that you can put in.
1 2 3 |
SYNTAX Invoke-Expression [-Command] |