Hi Actually this question is related to every web query giving back an html page A silly question from a dumb powersheller ;) I'm using Powershell 4.0 Here is my query:
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true} $url = "https://myprtg.domain.tld/api/duplicateobject.htm?id=61222&name=9998 FIX: Uptime&targetid=63040&username=me&password=pass"
When I do:
$result = Invoke-WebRequest $url
I have an error (since the beginning for all my functions):
Invoke-WebRequest : The underlying connection was closed: An unexpected error occurred on a send. At line:1 char:11 + $result = Invoke-WebRequest $url + ~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
I used to make it like this instead:
$wc = New-Object System.Net.WebClient $url = "https://myprtg.domain.tld/api/duplicateobject.htm?id=61222&name=9998 FIX: Uptime&targetid=63040&username=me&password=pass" $result = $wc.DownloadString($url) $html = New-Object -ComObject "HTMLFile" $html.IHTMLDocument2_write($result) $html.forms | % innerhtml
This last line gives back the whole form but I can't figure out how to get the new sensor id only Do you have any suggestion? Thank you upfront
Add comment