We all know that many unix shells have it and the format for powershell is $ (command ). But I can’t find it documented anywhere. In the first edition of the book powershell TFM, it is mentioned, but the later edition lacks it. is it still around? I tried mkdir $ (1+3) and received error
mkdir : A positional parameter cannot be found that accepts argument ‘4’.
At line:1 char:1
Is called a subexpression, and it’s valid inside double quotes. Notice there is no space between the dollar sign and the parentheses. You used a space; that passed $ as the first argument, and 4 (the result of the expression 1+3) as a second parameter. The command didn’t know what to do with the second parameter.
If your goal was to create a directory named 4, you don’t need to use a subexpression.
mkdir (1+3)
Would have worked. Parenthetical expressions are always evaluated first, and the result passed to whatever parameter.