1

I am new to powershell and run into a weird error from:

\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

Some suggestions?

mklement0
  • 382,024
  • 64
  • 607
  • 775
David Z
  • 6,641
  • 11
  • 50
  • 101

1 Answers1

2

Unlike POSIX-compatible shells such as Bash, PowerShell requires use of the $ prefix symbol also when creating (assigning to) variables, no just when getting their values.

Therefore:

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

Note: Consider using a '...' string for verbatim content.

Without the $, dlurl is interpreted as a command name and everything that comes after as its arguments, which explains the error you saw (no command by that name exists on your system).

See also:

  • The conceptual about_Variables help topic.

  • 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 this answer.

mklement0
  • 382,024
  • 64
  • 607
  • 775