Powershell Invoke-RestMethod return -


i running powershell 2.0. new powershell , using run php script on daily basis don't have continually call url in browser myself. seem have working pretty can't seem json return invoke-restmethod. here code using:

$limit = 200; ($i=1; $i -le $limit; $i++) {                               write-host $i started of $limit     $site = "http://example.com/updates"     $info = measure-command{         $data = @{call_type = 'powershell'}         $resp = (invoke-restmethod -method post -uri $site -body $data -timeoutsec 500).results            }     write-host resp - on $resp.date, $resp.num downloaded      write-host $i took $info.totalseconds s      write-host --------------------------------------- } 

the php script passing json string like:

{date: '2014-09-30', num: 127569} 

any great.

you don't need .results. invoke-restmethod converts json [psobject] automatically.

if want raw json use invoke-webrequest, since reference $resp.date , $resp.num seems wanted conversion after all.


Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

order - Notification for user in user account opencart -