質問者
認証proxy下でInvoke-WebRequest

質問
すべての返信
-
こんな感じでやってもうまくいかないんですよね。
$secPasswd=ConvertTo-SecureString "password" -AsPlainText -Force
$myCreds=New-Object System.Management.Automation.PSCredential -ArgumentList "hogeuser",$secPasswdInvoke-WebRequest -Headers $Headers -Uri "https://hogehoge" -Proxy 'https://proxy.com:8080' -proxyCredential $myCreds
Invoke-WebRequest : 競合する次のパラメーターが指定されているため、コマンドレットを実行できません: ProxyCredential および ProxyUseDefaultCredentials。ProxyCredential と ProxyUseDefaultCredentials のいずれかを指定して再試行してください
-
チャブーンです。
よくわからないですが、-headersと -proxyCredentialの両方を書いているからかもしれません。
したのページで-headersのみの動作(事前に$Headersの内容定義がいりますが)で動いた、という記述がありますので、参考にしてみてはいかがでしょうか?
フォーラムは有償サポートとは異なる「コミュニティ」です。フォーラムでご質問頂くにあたっての注意点 をご一読のうえ、お楽しみください。
-
proxyがhttpsを要求するなら、そもそもInvoke-WebRequest(というか.NETのWebReqeust)自体を使えないかも。
The ServicePointManager does not support proxies of https scheme (.NET 1.1 SP1)
-
試してみましたが、やはり-Proxyを設定して、かつ -ProxyCredentialを指定した場合は
-ProxyUseDefaultCredentials:$false を追加しないとエラーになります。お試しを
ありがとうございます。実行してみました。
Invoke-WebRequest -Uri "https://hogehoge" -Proxy 'https://proxy.com:8080' -proxyCredential $myCreds -ProxyUseDefaultCredentials:$false
次のようなエラーがでてしまいます。
Invoke-WebRequest : ERROR
Cache Access Denied.
The following error was encountered while trying to retrieve the URL: https://hogehoge/*
Cache Access Denied.
Sorry, you are not currently allowed to request https://hogehoge/* from this cache until you have authenticated yourself.
Please contact the cache administrator if you have difficulties authenticating yourself or change your default password.
-
チャブーンです。
Proxy認証ですが、Windows統合認証でしょうか?(平文の)基本認証なのではないでしょうか?
その場合ですが、したの情報の「Manually build the headers」のコードを試してみてはどうでしょうか?
追記:
それと、実行したコードですが、ProxyのURIが「HTTPS」になっていますが、本当にHTTPSなのでしょうか?HTTPならば正しいURIを記載したほうがよろしいかと。
フォーラムは有償サポートとは異なる「コミュニティ」です。フォーラムでご質問頂くにあたっての注意点 をご一読のうえ、お楽しみください。
- 編集済み チャブーンMVP 2015年11月9日 11:32