Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/http/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell http POST调用WebRequest参数添加文本_Powershell_Http_Batch File_Httpwebrequest_Invoke Command - Fatal编程技术网

Powershell http POST调用WebRequest参数添加文本

Powershell http POST调用WebRequest参数添加文本,powershell,http,batch-file,httpwebrequest,invoke-command,Powershell,Http,Batch File,Httpwebrequest,Invoke Command,我可以得到纯文本显示,我可以得到一个变量,然后文本显示-然而,我试图得到例如,一个标签,然后变量: Computer Name: $env:computername 返回错误 我正在使用的批处理命令是: powershell-Command”&{Invoke-WebRequest-Urihttps://script.google.com/macros/s//exec -Method POST-Body text=“$env:computername,$env:os,$env:usernam

我可以得到纯文本显示,我可以得到一个变量,然后文本显示-然而,我试图得到例如,一个标签,然后变量:

Computer Name: $env:computername 
返回错误

我正在使用的批处理命令是:


powershell-Command”&{Invoke-WebRequest-Urihttps://script.google.com/macros/s//exec -Method POST-Body text=“$env:computername,$env:os,$env:username,$env:thisip”}”
@thepip3r正确指出:


看起来您的问题与单引号中的单引号有关 引用。您需要对内部单引号或字符串进行双引号 正在被解释为在字符串中间终止

我改到下面,它工作了:


powershell-Command”&{Invoke-WebRequest-Urihttps://script.google.com/macros/s//exec -方法POST-Body text='ComputerName:$env:ComputerName,OS:$env:OS,UserName:$env:UserName,IP:$env:thisip'}“
看起来您的问题与单引号中的单引号有关。您需要对内部单引号加双引号,否则该字符串将被解释为以mid-string.duh结尾。谢谢你的帮助!很容易错过这些东西!谢谢你的帮助!