How to use wget in PowerShell console with username and password How to use wget in PowerShell console with username and password powershell powershell

How to use wget in PowerShell console with username and password


It looks like you actually want to run the program wget.exe, but PowerShell has a builtin alias wget for the cmdlet Invoke-WebRequest that takes precedence over an executable, even if the executable is in the PATH. 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:

wget.exe --user 'My.UserName@gmail.com' --password 'MyWhatEver@pas$w0rd' https://bitbucket.org/WhatEver/WhatEverBranchName/get/master.zip

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 the wget executable you need to provide credentials via a PSCredential object:

$uri  = 'https://bitbucket.org/WhatEver/WhatEverBranchName/get/master.zip'$user = 'My.UserName@gmail.com'$pass = 'MyWhatEver@pas$w0rd' | ConvertTo-SecureString -AsPlainText -Force$cred = New-Object Management.Automation.PSCredential ($user, $pass)Invoke-WebRequest -Uri $uri -Credential $cred