dlurl : 术语 'dlurl' 未被识别为 cmdlet、函数、脚本文件或可运行程序的名称

dlurl : The term 'dlurl' is not recognized as the name of a cmdlet, function, script file, or operable program

我是 powershell 的新手,运行 遇到了一个奇怪的错误:

\Downloads> dlurl = "https://s3.amazonaws.com/aws-cli/AWSCLI64PY3.msi"
dlurl : The term 'dlurl' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ dlurl = "https://s3.amazonaws.com/aws-cli/AWSCLI64PY3.msi"
+ ~~~~~
    + CategoryInfo          : ObjectNotFound: (dlurl:String) [], CommandNotFoundException

有什么建议吗?

与 POSIX 兼容的 shell 不同,例如 Bash,PowerShell 在 创建 [=41 时也需要使用 $ 前缀符号=](分配给)变量,不只是在获取它们的值时。

因此:

$dlurl = "https://s3.amazonaws.com/aws-cli/AWSCLI64PY3.msi"

注意:考虑对逐字内容使用'...'字符串。

如果没有 $dlurl 将被解释为 命令名称 以及其后的所有内容作为其 参数 ,它解释了您看到的错误(您的系统上不存在该名称的命令)。

另请参阅:

  • 概念性 about_Variables 帮助主题。

  • about_Parsing, which explains PowerShell's two fundamental parsing modes, argument mode (shell-like), and expression mode (programming-language-like); it is the first token of a statement that determines what mode is entered. A more systematic overview can be found in .