简体   繁体   English

Powershell 到 PHP 脚本

[英]Powershell to PHP script

I'm on a PowerShell script which return me information from distant servers I want to enter this information in a database by passing it to PHP我正在使用 PowerShell 脚本,该脚本从远程服务器返回信息我想通过将其传递给 PHP 将这些信息输入到数据库中

PowerShell:电源外壳:

$postParams = @{ "site" = $localname; "comp" = $retrunvalue }
$req = Invoke-WebRequest -Uri ("http://server_adress.com/index.php") 
-Method POST -Body $postParams

and on PHP:在 PHP 上:

<?php    
    if(isset($_POST['site']) and isset($_POST['comp']))
    {
        echo 'Thanks';
    }
    else 
    {
        echo 'non reachable values';
    }
?>

But when I go to the website page I have an error saying that non reachable values (my code)但是当我转到网站页面时,我有一个错误说无法访问的值(我的代码)

How can I fix this?我怎样才能解决这个问题?

hello everyBody i found finally something very powerfull !大家好,我终于找到了一些非常强大的东西! with Powershell v3 we could use directly POST method !!使用 Powershell v3 我们可以直接使用 POST 方法!! $URL = " http://example.com/foo/bar.php " $URL = " http://example.com/foo/bar.php "

$postparam = @{TESTID= "524"; $postparam = @{TESTID="524"; sitename = $localname;站点名称 = $localname; comp = 4;补偿 = 4; stream = "foo" }流 = "foo" }

    $webrequest = Invoke-RestMethod -Uri $URL -Body $postparam -Method Post

Thanks i hope this will help someone !谢谢我希望这会帮助某人!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM