I am unable to understand Parameter passing behavior in Powershell.
Say, I have a script callScript.ps1
param($a="DefaultA",$b="DefaultB")
echo $a, $b
Say, another script calls callScript.ps1.
.\callScript.ps1
# outputs DefaultA followed by DefaultB as expected
.\callScript.ps1 -a 2 -b 3
# outputs 2 followed by 3 as expected
$arguments='-a 2 -b 3'
callScript.ps1 $arguments
# I expected output as previous statement but it is as follows.
# -a 2 -b 3
# DefaultB
How can I run a powershell script by constructing command dynamically as above?
Can you please explain why the script the $arguments is interpreted as $a variable in callScript.ps1?