I am working on a webpage login monitor on a page that has three fields. I have been able to get it to work outside of Orion, but when trying to create a powershell monitor I get the following error: I have found that it is due to the fact that '-UseBasicParsing' isnt pulling the form or the inputfields. Has anyone figured out a way around this? Is IE supposed
Invoke-WebRequest : The response content cannot be parsed because the Internet Explorer engine is not available, or Internet Explorer's first-launch configuration is not complete. Specify the UseBasicParsing parameter and try again.
At line:3 char:6
+ $r = Invoke-WebRequest -Uri ($loginURL + 'logonform.jsp')
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotImplemented: (:) [Invoke-WebRequest], NotSupportedException
+ FullyQualifiedErrorId : WebCmdletIEDomNotSupportedException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
So, I add '-UseBasicParsing' and then all I get is this:
Cannot index into a null array.
At line:5 char:1
+ $form = $r.Forms[0];
+ ~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : NullArray
I have found that it is due to the fact that '-UseBasicParsing' isnt pulling the form or the inputfields. Has anyone figured out a way to get this to work? These are based on IE. Is IE usable for powershell monitors or does application monitoring go some other route. Just to make sure I brought up IE on the poller and made sure that the sites I am trying to monitor with this are part of the trusted sites.
Here is the source code:
$loginbase = '<input omitted>'
$loginURL = $loginbase + '<input omitted>'
$r = Invoke-WebRequest -Uri ($loginURL + 'logonform.jsp') -UseBasicParsing
return $r;
$form = $r.Forms[0];
return $form
$form.Fields['aps'] = '<input omitted>';
$form.Fields['usr'] = '<input omitted>';
$form.Fields['pwd'] = '<input omitted>';
$r = Invoke-WebRequest -Uri ($loginURL + $form.Action) -Method POST -Body $form.Fields;
if ($r.Content -match 'setup()') {
if ($r.StatusCode -eq 200) {
Write-Host 'Message:' $r.StatusDescription;
Write-Host 'Statistic:' $r.StatusCode;
Exit 0;
}
Write-Host 'Message:' $r.StatusDescription;
Write-Host 'Statistic:' $r.StatusCode;
Exit 1;
}
Write-Host 'Message: Did not login';
Write-Host 'Statistic: 1';
Exit 1;