php - Send powershell results to HTTP -
Sorry to be a newbie in this, but later on to show me a positive result in a PHP page for processing There is something to learn in
I tried this code:
$ test1 = "test" $ postParams = @ {test = $ test1} Avai-WebsterWest-URI http: // bu01 / Stats /input.php - Method Post - body $ postParams which works fine, receives string test in PHP $ _POST ['test']
But when trying to parse more data like this:
$ test1 = get-WMIobject win32_logicaldisk | Selection-Object Device ID, FreeSpace, Size $ PostParam = @ {Test = $ Test 1} Invec-WebUuVest-URI http: //bu01/stats/input.php- Law Post - Body $ Post Parameters <All the results I have found are "System.Object []".
How to send PHP?
Thank you!
UPDATE: Thanks for your suggestions, I created the following script with a foreach to post each "line" in a different web request. Which works fine for now, has not been tested with HD space, but with whitepaper in Exchange DB, but the idea is the same.
$ dbs = Get-MailboxDatabase -Status | Selection-object name, Database Sources, available emailmailspace Forex currency ($ $ IN $ dbs) {$ data = $ a.Name + ',' + $ a.DatabaseSize.ToKB () + ',' + $ a.AvailableNewMailboxSpace.ToKB () $ PostParams = @ {Data = $ Data} Invitation-webUurUst-URI http: //bu01/stats/input.php- Law Post - Body $ Post Parameters} Maybe someone Is there a good tip to change it in a request? It is much more efficient for the web server.
Actually, your first example is an HTTP request because it's a simple bit of text. Your second example , Though, as a result (guess what?) System. Object object then PowerShell failed to force type for you, because the HTTP payload requires some text if you wanted to do something like $ test1 [0]. Device IDTrace (), which will be most likely - the first item For, at least BTW, .toString () may not be required - To determine whether this depends on the 'Type' of the DeviceID attribute, make $ test1 [0] .DeviceID.GetType ()
If you were given by your WMI call So brake example need to process, you will have access to post separately to each frequency, Foreach-Object {}. Or ... use the Foreach-Object {} to insert relevant information, and post it as a one, properly demoted, text string.
You may also need to use UrlEncode (.NET Call) to encode any strange characters in your data.
Comments
Post a Comment