2016-10-01 40 views
0

私はthisthisのように答えを数回見ました。しかし、私はいつも以下のようないくつかのエラーが発生します。PowerShellコンソールでwgetをユーザー名とパスワードで使用する方法

私は何が間違っているのか分かりません。私は以下のバリエーションを試してみましたが、すべて同様のエラーが発生します。助けてください。

wget --user "[email protected]" --password "[email protected]$w0rd" https://bitbucket.org/WhatEver/WhatEverBranchName/get/master.zip 
wget --user="[email protected]" --password="[email protected]$w0rd" https://bitbucket.org/WhatEver/WhatEverBranchName/get/master.zip 
wget --user='[email protected]' --password='[email protected]$w0rd' https://bitbucket.org/WhatEver/WhatEverBranchName/get/master.zip 
wget --user [email protected] --password [email protected]$w0rd https://bitbucket.org/WhatEver/WhatEverBranchName/get/master.zip 
Invoke-WebRequest : A positional parameter cannot be found that accepts argument 
'[email protected]$w0rd'. 
At line:1 char:1 
+ wget --user='[email protected]' --password='[email protected]$w0rd' ... 
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    + CategoryInfo   : InvalidArgument: (:) [Invoke-WebRequest], ParameterBindingException 
    + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

答えて

1

実行ファイルがPATHにある場合でも、あなたが実際にプログラムwget.exeを実行したいように見えますが、PowerShellは、実行上precedenceを取るコマンドレットInvoke-WebRequestための組み込みエイリアスwgetを持っています。そのコマンドレットには、--userまたは--passwordというパラメータがありません。これが原因で発生したエラーの原因です。

PowerShellは別名と混同しないようにするには、その拡張子を追加することによって、実行可能ファイルを実行している強制することができます:あなたはそれ以外の場合は、単一引用符で$などの特殊文字と文字列リテラルを置くべきであると

wget.exe --user '[email protected]' --password '[email protected]$w0rd' https://bitbucket.org/WhatEver/WhatEverBranchName/get/master.zip 

注意を変数$w0rdが定義されていないため、PowerShellは"[email protected]$w0rd""[email protected]"に展開します。

あなたはむしろあなたがPSCredentialオブジェクトを介して認証情報を提供する必要がwget実行可能なよりもコマンドレットInvoke-WebRequestを使用する場合:

$uri = 'https://bitbucket.org/WhatEver/WhatEverBranchName/get/master.zip' 
$user = '[email protected]' 
$pass = '[email protected]$w0rd' | ConvertTo-SecureString -AsPlainText -Force 
$cred = New-Object Management.Automation.PSCredential ($user, $pass) 

Invoke-WebRequest -Uri $uri -Credential $cred 
+0

おかげで、あなたが言ったことは理にかなっています。 – VivekDev

関連する問題