我之前在Excel VBA中使用过以下代码,它将变量发布到我网站上的PHP脚本并获取返回值:
<script>
myURL = "http://www.example.com/Scripts/myscript.php?password=password"
winHttpReq.Open "POST", myURL, False
winHttpReq.SetRequestHeader "Content-Type", "application/x-www-form- urlencoded"
winHttpReq.Send
msgbox winHttpReq.responseText
</script>
我想在Powershell中做类似的事情但找不到任何东西?提前谢谢。
答案 0 :(得分:0)
发现它!!
$r = [System.Net.WebRequest]::Create("http://www.example.com/Scripts/myscript.php?password=password")
$resp = $r.GetResponse()
$reqstream = $resp.GetResponseStream()
$sr = new-object System.IO.StreamReader $reqstream
$result = $sr.ReadToEnd()
write-host $result