Skip to content
Advertisement

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:

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

and on 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?

Advertisement

Answer

hello everyBody i found finally something very powerfull ! with Powershell v3 we could use directly POST method !! $URL = “http://example.com/foo/bar.php

$postparam = @{TESTID= “524”; sitename = $localname; comp = 4; stream = “foo” }

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

Thanks i hope this will help someone !

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement