The invocation operator, written &, runs a command whose executable name or path is stored in an expression. It is useful when PowerShell needs to run an external utility with values held in variables. section 4.7
Run an external utility from variables
$exe = "func" $action = "new" $language = "powershell" $template = "HttpTrigger" $name = "myFunc" & $exe $action -l $language -t $template -n $name PowerShell passes the executable, action, parameters, and values as separate command elements.
Use the operator when:
- The executable path or command name is supplied through a variable. section 4.7
- An external command is difficult for PowerShell to parse directly. section 4.7
- For PowerShell v3 and later, the --% stop-parsing symbol can pass literal arguments instead, but variables will not be expanded. section 4.7
$exe = "func" $action = "new" $language = "powershell" $template = "HttpTrigger" $name = "myFunc" & $exe $action -l $language -t $template -n $name
Browse the complete runnable pattern for invoking an external utility with command and parameter values stored in variables. section 4.7
