Hello!

I have task: Login into HTTPS web portal, open selected page on it, found line on those page and find the Value, then i need to set this Value in Sensor status. Which of standard sensor can help me with this?

Thank you!


Article Comments

The following might be helpful:
https://gist.github.com/stephanlinke/a145cae16c147e5cab0bed22e47bbf1b

Please make sure to read our Guide for PowerShell based custom Sensors :)


PRTG Scheduler | PRTGapi | Feature Requests | WMI Issues | SNMP Issues

Kind regards,
Stephan Linke, Tech Support Team


Oct, 2018 - Permalink

Hello!

When i import this script in PRTG into "Custom EXE/Script Sensor" i had following error:

Response not well-formed: "(Invoke-WebRequest : The response content cannot be parsed because the Internet Explorer engine is not available, or Internet Explorer's first-launch configura tion is not complete. Specify the UseBasicParsing parameter and try again. At C:\Program Files (x86)\PRTG Network Monitor\custom sensors\EXE\WebLogin.ps1: 30 char:15 + $loginPage = (Invoke-WebRequest -Uri "$url" -SessionVariable PRTG) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotImplemented: (:) [Invoke-WebRequest], NotSupp ortedException + FullyQualifiedErrorId : WebCmdletIEDomNotSupportedException,Microsoft.Po werShell.Commands.InvokeWebRequestCommand Cannot index into a null array. At C:\Program Files (x86)\PRTG Network Monitor\custom sensors\EXE\WebLogin.ps1: 34 char:1 + $LoginForm = $loginPage.Forms[$formId]; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : NullArray Cannot index into a null array. At C:\Program Files (x86)\PRTG Network Monitor\custom sensors\EXE\WebLogin.ps1: 35 char:1 + $LoginForm.Fields[$usernameId] = $username; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : NullArray Cannot index into a null array. At C:\Program Files (x86)\PRTG Network Monitor\custom sensors\EXE\WebLogin.ps1: 36 char:1 + $LoginForm.Fields[$passwordId] = $password; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : NullArray Cannot index into a null array. At C:\Program Files (x86)\PRTG Network Monitor\custom sensors\EXE\WebLogin.ps1: 37 char:1 + $LoginForm.Fields['body_0_content_0_sectioned_0_SignInButton'] = "Sig ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : NullArray Invoke-WebRequest : The response content cannot be parsed because the Internet Explorer engine is not available, or Internet Explorer's first-launch configura tion is not complete. Specify the UseBasicParsing parameter and try again. At C:\Program Files (x86)\PRTG Network Monitor\custom sensors\EXE\WebLogin.ps1: 39 char:12 + $result = (Invoke-WebRequest -Uri ($url) -WebSession $PRTG -Method PO ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotImplemented: (:) [Invoke-WebRequest], NotSupp ortedException + FullyQualifiedErrorId : WebCmdletIEDomNotSupportedException,Microsoft.Po werShell.Commands.InvokeWebRequestCommand You cannot call a method on a null-valued expression. At C:\Program Files (x86)\PRTG Network Monitor\custom sensors\EXE\WebLogin.ps1: 41 char:4 + if($result.Content.Contains($checkString)) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull )" (code: PE132)

What's wrong?


Nov, 2018 - Permalink

Please go through the following:
https://mkcheah88.blogspot.com/2014/06/microsoft-how-to-disable-internet.html

Invoke-WebRequest is using the IE DCOM object, which is blocked when the user hasn't started IE at least once, completing the wizard.


PRTG Scheduler | PRTGapi | Feature Requests | WMI Issues | SNMP Issues

Kind regards,
Stephan Linke, Tech Support Team


Nov, 2018 - Permalink

Yep, this done, but stays the following error:

Response not well-formed: "(0:Login successful - 'Overview' found. Invoke-WebRequest : Invalid URI: The hostname could not be parsed. At C:\Program Files (x86)\PRTG Network Monitor\custom sensors\EXE\WebLogin.ps1:45 char:5 + Invoke-WebRequest -Uri $logout -SessionVariable PRTG | Out-Null; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Invoke-WebRequest], UriFormatException + FullyQualifiedErrorId : System.UriFormatException,Microsoft.PowerShell.Commands.InvokeWebRe questCommand )" (code: PE132)


Nov, 2018 - Permalink

Hi Vasiliy,

Any chance you can post your current script? I am confused by the error you post - there seems to be a command LOGOUT URI / URL that is having an issue.. but I would like to see what you have so far first... not sure if I can help you with it - but it sounds interesting enough to try.

Regards

Florian Rossmark

www.it-admins.com


Nov, 2018 - Permalink

Perhaps the logout URL is wrongly configured/formatted - let's see what Vasiliy says :)


PRTG Scheduler | PRTGapi | Feature Requests | WMI Issues | SNMP Issues

Kind regards,
Stephan Linke, Tech Support Team


Nov, 2018 - Permalink

Yep, it's empty now, but actually i tried any url with no success and have no idea what must be there, no any description i found. :-(


Nov, 2018 - Permalink

The logout URL must be something like http://my-site/logout - i.e. the URL that is called when you click the logout button on the page. Otherwise, the session might persist throughout the calls and you're just checking the string, not the login functionality.


PRTG Scheduler | PRTGapi | Feature Requests | WMI Issues | SNMP Issues

Kind regards,
Stephan Linke, Tech Support Team


Nov, 2018 - Permalink