What is the difference between $a = $(Read-Host) and $a = (Read-Host)?

前端 未结 2 1684
小蘑菇
小蘑菇 2021-01-15 14:01

I have to review some scripts what my Ex-Colleague left behind and I am very curious why he is using $a = $(Read-Host -Prompt \"Write something\") in the Parame

2条回答
  •  死守一世寂寞
    2021-01-15 14:11

    $() is for evaluating subexpressions in strings. It does nothing here.

    You don't need () around read-host either, you can simply use $a = Read-Host -Prompt 'your input here'

    (-Prompt needs a string as parameter).

提交回复
热议问题