何らかの理由でこれが機能しない
Invoke-RestMethod -Uri "http://localhost" -Headers @{"Host"="web.domain.com"}
エラーが発生します
The 'Host' header must be modified using the appropriate property or method
しかし、これを行う方法に関するメソッドまたはプロパティが見つかりません。
ありがとう
何らかの理由でこれが機能しない
Invoke-RestMethod -Uri "http://localhost" -Headers @{"Host"="web.domain.com"}
エラーが発生します
The 'Host' header must be modified using the appropriate property or method
しかし、これを行う方法に関するメソッドまたはプロパティが見つかりません。
ありがとう
これは、 PowerShell バージョン 4.0で修正されたバグです。
C:\PS> (irm http://localhost -Headers @{Host='web.domain.com'}).html
xmlns head body
----- ---- ----
http://www.w3.org/1999/xhtml head body
記録のために、私は WebRequest を使用して問題を回避しました
$bytes = [system.Text.Encoding]::UTF8.GetBytes("key=value")
$web = [net.WebRequest]::Create("http://localhost") -as [net.HttpWebRequest]
$web.ContentType = "application/x-www-form-urlencoded"
$web.Host = "web.domain.com"
$web.Method = "POST"
$web.ContentLength = $bytes.Length
$stream = $web.GetRequestStream()
$stream.Write($bytes,0,$bytes.Length)