I have seen couple of answers on SO like this and this. But I always get some error similar to the following.
Not sure what am I doing wrong. I tried with the following variations, but all giving similar error. Please help.
wget --user "My.UserName@gmail.com" --password "MyWhatEver@pas$w0rd" https://bitbucket.org/WhatEver/WhatEverBranchName/get/master.zip
wget --user="My.UserName@gmail.com" --password="MyWhatEver@pas$w0rd" https://bitbucket.org/WhatEver/WhatEverBranchName/get/master.zip
wget --user='My.UserName@gmail.com' --password='MyWhatEver@pas$w0rd' https://bitbucket.org/WhatEver/WhatEverBranchName/get/master.zip
wget --user My.UserName@gmail.com --password MyWhatEver@pas$w0rd https://bitbucket.org/WhatEver/WhatEverBranchName/get/master.zip
Invoke-WebRequest : A positional parameter cannot be found that accepts argument '--password=MyWhatEver@pas$w0rd'. At line:1 char:1 + wget --user='My.UserName@gmail.com' --password='MyWhatEver@pas$w0rd' ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (:) [Invoke-WebRequest], ParameterBindingException + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
Best Answer
It looks like you actually want to run the program
wget.exe
, but PowerShell has a builtin aliaswget
for the cmdletInvoke-WebRequest
that takes precedence over an executable, even if the executable is in thePATH
. That cmdlet doesn't have parameters--user
or--password
, which is what causes the error you observed.You can enforce running the executable by adding its extension, so PowerShell doesn't confuse it with the alias:
Note that you should put string literals with special characters like
$
in single quotes, otherwise PowerShell would expand something like"MyWhatEver@pas$w0rd"
to"MyWhatEver@pas"
, because the variable$w0rd
is undefined.If you want to use the cmdlet
Invoke-WebRequest
rather than thewget
executable you need to provide credentials via aPSCredential
object: