none
Test-Net​Connection question RRS feed

  • Question

  • I could not find a more relevant forum.

    I use a Test_NetConnection command:

    tnc www.xxxx.yyy.zzz -Port 80

    And I get a successful response.: "TcpTestSucceeded : True"

    But when I enter the ip address in a browser (IE) I get "Can’t reach this page"

    So What did tnc test to declare a success when Internet Explorer and EDGE fail?

    Please advise

    Boyd


    BDM

    Tuesday, December 11, 2018 7:37 PM

Answers

  • Test-netconnection is only looking to see that it can connect to the port. Try invoke-webrequest to see if it is responding with valid HTTP data. 

    PS C:\Users\Dave> invoke-webrequest 127.0.0.1

    StatusCode        : 200
    StatusDescription : OK
    Content           : <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
                        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
                        <html xmlns="http://www.w3.org/1999/xhtml">
                        <head>
                        <meta http-equiv="Content-Type" cont...
    RawContent        : HTTP/1.1 200 OK
                        Accept-Ranges: bytes
                        Content-Length: 696
                        Content-Type: text/html
                        Date: Tue, 11 Dec 2018 20:19:27 GMT
                        ETag: "da8e8183aae1d31:0"
                        Last-Modified: Wed, 02 May 2018 00:14:19 GMT
                        Serve...
    Forms             : {}
    Headers           : {[Accept-Ranges, bytes], [Content-Length, 696], [Content-Type, text/html], [Date, Tue, 11 Dec 201
                        20:19:27 GMT]...}
    Images            : {@{innerHTML=; innerText=; outerHTML=<IMG alt=IIS src="iisstart.png" width=960 height=600>;
                        outerText=; tagName=IMG; alt=IIS; src=iisstart.png; width=960; height=600}}
    InputFields       : {}
    Links             : {@{innerHTML=<IMG alt=IIS src="iisstart.png" width=960 height=600>; innerText=; outerHTML=<A
                        href="http://go.microsoft.com/fwlink/?linkid=66138&amp;clcid=0x409"><IMG alt=IIS
                        src="iisstart.png" width=960 height=600></A>; outerText=; tagName=A;
                        href=http://go.microsoft.com/fwlink/?linkid=66138&amp;clcid=0x409}}
    ParsedHtml        : System.__ComObject
    RawContentLength  : 696

    • Marked as answer by Boyd1 Tuesday, December 11, 2018 8:48 PM
    Tuesday, December 11, 2018 8:22 PM

All replies

  • Test-netconnection is only looking to see that it can connect to the port. Try invoke-webrequest to see if it is responding with valid HTTP data. 

    PS C:\Users\Dave> invoke-webrequest 127.0.0.1

    StatusCode        : 200
    StatusDescription : OK
    Content           : <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
                        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
                        <html xmlns="http://www.w3.org/1999/xhtml">
                        <head>
                        <meta http-equiv="Content-Type" cont...
    RawContent        : HTTP/1.1 200 OK
                        Accept-Ranges: bytes
                        Content-Length: 696
                        Content-Type: text/html
                        Date: Tue, 11 Dec 2018 20:19:27 GMT
                        ETag: "da8e8183aae1d31:0"
                        Last-Modified: Wed, 02 May 2018 00:14:19 GMT
                        Serve...
    Forms             : {}
    Headers           : {[Accept-Ranges, bytes], [Content-Length, 696], [Content-Type, text/html], [Date, Tue, 11 Dec 201
                        20:19:27 GMT]...}
    Images            : {@{innerHTML=; innerText=; outerHTML=<IMG alt=IIS src="iisstart.png" width=960 height=600>;
                        outerText=; tagName=IMG; alt=IIS; src=iisstart.png; width=960; height=600}}
    InputFields       : {}
    Links             : {@{innerHTML=<IMG alt=IIS src="iisstart.png" width=960 height=600>; innerText=; outerHTML=<A
                        href="http://go.microsoft.com/fwlink/?linkid=66138&amp;clcid=0x409"><IMG alt=IIS
                        src="iisstart.png" width=960 height=600></A>; outerText=; tagName=A;
                        href=http://go.microsoft.com/fwlink/?linkid=66138&amp;clcid=0x409}}
    ParsedHtml        : System.__ComObject
    RawContentLength  : 696

    • Marked as answer by Boyd1 Tuesday, December 11, 2018 8:48 PM
    Tuesday, December 11, 2018 8:22 PM
  • Ok, the original question has been answered.

    Now, can the output be logged in the Event Logger?

    That would be really cool.

    Boyd

    This almost works:

    PS H:\> write-eventlog -logname jacemonitor -source remotejacemonitor -entrytype Information -EventID 1 -Message myweb.txt

    But I get the -Message "myweb.txt"  instead of the content of the text file !?

    Please advise.


    BDM


    • Edited by Boyd1 Tuesday, December 11, 2018 10:14 PM
    Tuesday, December 11, 2018 9:38 PM