Options

Invoke-WebRequest returning the content as an error message rather than as an HTMLWebResponse

DevilsbaneDevilsbane Member Posts: 4,214 ■■■■■■■■□□
I'm trying to setup some monitoring on a server to alert when a service is not running properly. (I already have monitoring on the services themselves, but I occasionally see a service hang that still says its running when it isn't). I'm able to Invoke-WebRequest to the port I need and use the RawContentLength property to differentiate between a successful page load and a failed one.

But if I'm setting up monitoring anyway, I might as well add 443 to validate that the httpd service is working properly and that I get the Redhat test page. For some reason on one server I'm not getting back an HTMLWebResponse object, but the body of the page as an error message (and the same is true if I enable http and try hitting 80)..
 I'm tempted to just parse "Red Hat Enterprise Linux Test Page" out of the $error variable and call it a day but it's still nagging me why this one site is failing. I've tried a few different commands and can't figure out how to get a valid response. Is there something from apache that is not configured properly?
Decide what to be and go be it.
Tagged:

Answers

  • Options
    thomas_thomas_ Member Posts: 1,012 ■■■■■■■■□□
    Can you look at the traffic using Wireshark?  What HTTP status code is sent back with the page?  My guess would be the HTTP status code is what is causing the error message.

    Does $error[0].exception or $error[0].exception.innerexception return anything useful after the error occurs?
Sign In or Register to comment.