Sorry for being a newbie in this, but I want to learn something about sending powershell results to a PHP page for later processing.
I tried this code:
$test1 = "test"
$postParams = @{test=$test1}
Invoke-WebRequest -Uri http://bu01/stats/input.php -Method POST -Body $postParams
Which works fine, PHP receives the string test in $_POST['test']
But when trying to parse more data, like this:
$test1 = Get-WMIobject win32_logicaldisk | select-object DeviceID,FreeSpace,Size
$postParams = @{test=$test1}
Invoke-WebRequest -Uri http://bu01/stats/input.php -Method POST -Body $postParams
All result I got is "System.Object[]".
Please explain how to send it to PHP.
Thanks!
UPDATE: Thanks for your tips. I made the following script with foreach to post each "row" in a seperate web request. Which works fine for now. No longer testing with hdd space, but with whitespace in Exchange DB's, but the idea is the same.
$dbs = Get-MailboxDatabase -Status | select-object Name, DatabaseSize, AvailableNewMailboxSpace
foreach ($a in $dbs){
$data = $a.Name+','+$a.DatabaseSize.ToKB()+','+$a.AvailableNewMailboxSpace.ToKB()
$postParams = @{data=$data}
Invoke-WebRequest -Uri http://bu01/stats/input.php -Method POST -Body $postParams
}
Maybe someone has a good tip to transform this into one request? This is much more efficient for the web server.