Home > front end >  dlurl : The term 'dlurl' is not recognized as the name of a cmdlet, function, script file,
dlurl : The term 'dlurl' is not recognized as the name of a cmdlet, function, script file,

Time:12-17

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?

CodePudding user response:

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.

  • Related