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结尾。谢谢你的帮助!很容易错过这些东西!谢谢你的帮助!