none
PowerShell Internetexplorer.Application things are missing

    Question

  • I've upgraded a pc to Win 7. Now, when I want to use Internetexplorer.Application as a COM object in PowerShell, I notice important things are missing. For example, there's no body object.

    $ie = new-object -com internetexplorer.application
    $ie.navigate('www.somesite.com')
    while while ($ie.busy -eq $true) {
    Start-Sleep -Milliseconds 600
    }
    $ie.document.body | select innerhtml

    no output at all, because of the fact there's no body. The only elements I have at this moment:

    addEventListener
    appendChild
    attachEvent
    clear
    cloneNode
    close
    compareDocumentPosition
    createElementNS
    createEvent
    createEventObject
    createNodeIterator
    createProcessingInstruction
    createRange
    createStyleSheet
    createTextNode
    createTreeWalker
    detachEvent
    dispatchEvent
    elementFromPoint
    execCommand
    execCommandShowHelp
    fireEvent
    focus
    getElementById
    getElementsByClassName
    getElementsByName
    getElementsByTagName
    getElementsByTagNameNS
    getSelection
    hasAttributes
    hasChildNodes
    hasFocus
    importNode
    insertBefore
    isDefaultNamespace
    isEqualNode
    isSameNode
    isSupported
    lookupNamespaceURI
    lookupPrefix
    normalize
    open
    queryCommandEnabled
    queryCommandIndeterm
    queryCommandState
    queryCommandSupported
    queryCommandText
    queryCommandValue
    querySelector
    querySelectorAll
    releaseCapture
    removeChild
    removeEventListener
    removeNode
    replaceChild
    replaceNode
    swapNode
    write
    writeln

    What to I have to do / install to get the elements like body, all etc.

    Sunday, December 05, 2010 4:00 PM

Answers

  • Hi,

    It is weird, but sounds more like a Windows support question than a scripting question?

    Bill

    Monday, December 06, 2010 9:02 PM
    Moderator
  • Anyway, many thanks for your help !

    Mark

    • Marked as answer by digistam Tuesday, December 07, 2010 1:02 PM
    Tuesday, December 07, 2010 1:01 PM
  • I couldn't let it go and I've analyzed it a bit more. It seems there's still a lack of published information with regard to the Internetexplorer.Application COM object. On this specific computer I'm able to use this command:

    $ie = new-object -comobject internetexplorer.application
    $ie.navigate('www.google.com')
    $ie.document.documentelement.all

    And now the contents of the webpage appears in my PowerShell console.

    When I want to list the contents of the body element, I can do this:

    $ie.document.documentelement.getelementsbytagname('body')

    There's still a lot to find out, but I think I'm on the right track now. Thanks y'all for your help !

    Mark

    • Marked as answer by digistam Tuesday, December 07, 2010 2:22 PM
    Tuesday, December 07, 2010 2:20 PM

All replies

  • If I do this on Windows 7  with IE8

    $ie = new-object -com internetexplorer.application
    $ie.navigate('www.google.com')
    while ($ie.busy -eq $true) {
    Start-Sleep -Milliseconds 600
    }
    $ie.Document.Body 
    
    
    

    I get the entire page content dumped to the console. I get these properties/members

    Name                                MemberType
    ----                                ----------
    addBehavior                             Method
    addFilter                               Method
    appendChild                             Method
    applyElement                            Method
    attachEvent                             Method
    blur                                    Method
    clearAttributes                         Method
    click                                   Method
    cloneNode                               Method
    componentFromPoint                      Method
    contains                                Method
    createControlRange                      Method
    createTextRange                         Method
    detachEvent                             Method
    doScroll                                Method
    dragDrop                                Method
    FireEvent                               Method
    focus                                   Method
    getAdjacentText                         Method
    getAttributeNode                        Method
    getBoundingClientRect                   Method
    getClientRects                          Method
    getElementsByTagName                    Method
    getExpression                           Method
    hasAttribute                            Method
    hasAttributes                           Method
    hasChildNodes                           Method
    ie8_getAttribute                        Method
    ie8_getAttributeNode                    Method
    ie8_removeAttribute                     Method
    ie8_removeAttributeNode                 Method
    ie8_setAttribute                        Method
    ie8_setAttributeNode                    Method
    insertAdjacentElement                   Method
    insertAdjacentHTML                      Method
    insertAdjacentText                      Method
    insertBefore                            Method
    mergeAttributes                         Method
    normalize                               Method
    releaseCapture                          Method
    removeAttributeNode                     Method
    removeBehavior                          Method
    removeChild                             Method
    removeExpression                        Method
    removeFilter                            Method
    removeNode                              Method
    replaceAdjacentText                     Method
    replaceChild                            Method
    replaceNode                             Method
    scrollIntoView                          Method
    setActive                               Method
    setAttributeNode                        Method
    setCapture                              Method
    setExpression                           Method
    swapNode                                Method
    toString                                Method
    accessKey                             Property
    aLink                                 Property
    all                                   Property
    ariaActivedescendant                  Property
    ariaBusy                              Property
    ariaChecked                           Property
    ariaControls                          Property
    ariaDescribedby                       Property
    ariaDisabled                          Property
    ariaExpanded                          Property
    ariaFlowto                            Property
    ariaHaspopup                          Property
    ariaHidden                            Property
    ariaInvalid                           Property
    ariaLabelledby                        Property
    ariaLevel                             Property
    ariaLive                              Property
    ariaMultiselectable                   Property
    ariaOwns                              Property
    ariaPosinset                          Property
    ariaPressed                           Property
    ariaReadonly                          Property
    ariaRelevant                          Property
    ariaRequired                          Property
    ariaSecret                            Property
    ariaSelected                          Property
    ariaSetsize                           Property
    ariaValuemax                          Property
    ariaValuemin                          Property
    ariaValuenow                          Property
    attributes                            Property
    background                            Property
    behaviorUrns                          Property
    bgColor                               Property
    bgProperties                          Property
    bottomMargin                          Property
    canHaveChildren                       Property
    canHaveHTML                           Property
    childNodes                            Property
    children                              Property
    clientHeight                          Property
    clientLeft                            Property
    clientTop                             Property
    clientWidth                           Property
    constructor                           Property
    contentEditable                       Property
    currentStyle                          Property
    dir                                   Property
    disabled                              Property
    document                              Property
    filters                               Property
    firstChild                            Property
    glyphMode                             Property
    hideFocus                             Property
    ie8_attributes                        Property
    ie8_background                        Property
    inflateBlock                          Property
    innerHTML                             Property
    innerText                             Property
    isContentEditable                     Property
    isDisabled                            Property
    isMultiLine                           Property
    isTextEdit                            Property
    lang                                  Property
    language                              Property
    lastChild                             Property
    leftMargin                            Property
    link                                  Property
    nextSibling                           Property
    nodeName                              Property
    nodeType                              Property
    nodeValue                             Property
    noWrap                                Property
    offsetHeight                          Property
    offsetLeft                            Property
    offsetParent                          Property
    offsetTop                             Property
    offsetWidth                           Property
    onactivate                            Property
    onafterprint                          Property
    onafterupdate                         Property
    onbeforeactivate                      Property
    onbeforecopy                          Property
    onbeforecut                           Property
    onbeforedeactivate                    Property
    onbeforeeditfocus                     Property
    onbeforepaste                         Property
    onbeforeprint                         Property
    onbeforeunload                        Property
    onbeforeupdate                        Property
    onblur                                Property
    oncellchange                          Property
    onclick                               Property
    oncontextmenu                         Property
    oncontrolselect                       Property
    oncopy                                Property
    oncut                                 Property
    ondataavailable                       Property
    ondatasetchanged                      Property
    ondatasetcomplete                     Property
    ondblclick                            Property
    ondeactivate                          Property
    ondrag                                Property
    ondragend                             Property
    ondragenter                           Property
    ondragleave                           Property
    ondragover                            Property
    ondragstart                           Property
    ondrop                                Property
    onerrorupdate                         Property
    onfilterchange                        Property
    onfocus                               Property
    onfocusin                             Property
    onfocusout                            Property
    onhashchange                          Property
    onhelp                                Property
    onkeydown                             Property
    onkeypress                            Property
    onkeyup                               Property
    onlayoutcomplete                      Property
    onload                                Property
    onlosecapture                         Property
    onmousedown                           Property
    onmouseenter                          Property
    onmouseleave                          Property
    onmousemove                           Property
    onmouseout                            Property
    onmouseover                           Property
    onmouseup                             Property
    onmousewheel                          Property
    onmove                                Property
    onmoveend                             Property
    onmovestart                           Property
    onoffline                             Property
    ononline                              Property
    onpage                                Property
    onpaste                               Property
    onpropertychange                      Property
    onreadystatechange                    Property
    onresize                              Property
    onresizeend                           Property
    onresizestart                         Property
    onrowenter                            Property
    onrowexit                             Property
    onrowsdelete                          Property
    onrowsinserted                        Property
    onscroll                              Property
    onselect                              Property
    onselectstart                         Property
    onunload                              Property
    outerHTML                             Property
    outerText                             Property
    ownerDocument                         Property
    parentElement                         Property
    parentNode                            Property
    parentTextEdit                        Property
    previousSibling                       Property
    readyState                            Property
    readyStateValue                       Property
    recordNumber                          Property
    rightMargin                           Property
    role                                  Property
    runtimeStyle                          Property
    scopeName                             Property
    scroll                                Property
    scrollHeight                          Property
    scrollLeft                            Property
    scrollTop                             Property
    scrollWidth                           Property
    sourceIndex                           Property
    style                                 Property
    tabIndex                              Property
    tagName                               Property
    tagUrn                                Property
    text                                  Property
    title                                 Property
    topMargin                             Property
    uniqueID                              Property
    uniqueNumber                          Property
    vLink                                 Property

    Sunday, December 05, 2010 9:17 PM
  • Hi Xenophane,

    I know, your result is what supposed to be the right result. But, in my case, I also use Win7 and IE8 but in my case most of the properties, members etc. like "body" is missing. So, I suppose I have to install some additional things instead of only IE8 but I don't know what.

     

    Thanks,

    Mark

    Sunday, December 05, 2010 10:01 PM
  • You're not missing anything.  If I follow, you're issue is that you don't see "body"?  I don't know what these are technically, called, but these "properties of properties" won't get listed from a direct get-member.
    Monday, December 06, 2010 3:16 AM
    Moderator
  • Thank you for your reply ! However, there's something missing in my Win 7 install. I have multiple computers and servers working with the Internet Explorer com object. They all have the "document.body" and the "document.all" element (properties). I have reinstalled Win 7 on my netbook and now the "document.body" and "document.all" elements are missing in this install. In the former Win 7 install the "document.body" and "document.all" elements / properties worked without problems.

    I really hope there is somebody who knows the solution to this strange problem.

    Mark

    Monday, December 06, 2010 7:20 PM
  • Hi,

    It is weird, but sounds more like a Windows support question than a scripting question?

    Bill

    Monday, December 06, 2010 9:02 PM
    Moderator
  • $ie = new-object -com internetexplorer.application
    $ie.navigate('www.google.com.hk')
    while ($ie.busy -eq $true) {
    Start-Sleep -Milliseconds 600
    }
    $ie.document.body.Innerhtml

    this is OK

    Tuesday, December 07, 2010 7:05 AM
  • Anyway, many thanks for your help !

    Mark

    • Marked as answer by digistam Tuesday, December 07, 2010 1:02 PM
    Tuesday, December 07, 2010 1:01 PM
  • I couldn't let it go and I've analyzed it a bit more. It seems there's still a lack of published information with regard to the Internetexplorer.Application COM object. On this specific computer I'm able to use this command:

    $ie = new-object -comobject internetexplorer.application
    $ie.navigate('www.google.com')
    $ie.document.documentelement.all

    And now the contents of the webpage appears in my PowerShell console.

    When I want to list the contents of the body element, I can do this:

    $ie.document.documentelement.getelementsbytagname('body')

    There's still a lot to find out, but I think I'm on the right track now. Thanks y'all for your help !

    Mark

    • Marked as answer by digistam Tuesday, December 07, 2010 2:22 PM
    Tuesday, December 07, 2010 2:20 PM
  • Hi digistam:

    I´ve encounter the same problem you have, but in a different way.

    I
    am developing a script on Powershell but using the PoweGUI debugger
    through Visual studio 2010. I guess Visual Studio uses the parsing
    ability of the powerGUI library just because the same enviroment is
    used, well the problem is that i have developed the script depending
    some of my functions on the parsing of DOM objects for HTML using the
    internet.explorer object.

    works perfectly if i run it on
    visualstudio but doesnt work if i run it on Powershell ISE or normal
    command prompt.I would assume the script uses different libraries
    depending on where the script runs from. I had the same problem with a
    PHP CLI or Webserver runned application.

    Have you found the answer to your problem??? because i haven't.

    this is very weird.

    Thanxs!

    Thursday, September 13, 2012 4:34 PM
  • This is not a PHP or Visual studio forum.  FOr PowerGUI yu need to contact teh vendor.

    If you have a POwerSHell script that is an issue then you need to post the script.

    You also need to start a new topisc as this one has been closed for almost two years and you question really has nothing to do with the original topic.

    Start a topic and post you powershell script with all complete error messages.

    Thank you.

    Note that this works fine for me on Windows 7 from ISE or from PowerGUI.

    $ie = new-object -com internetexplorer.application
    $ie.navigate('www.google.com')
    while($ie.busy){Start-Sleep -Milliseconds 100}
    $ie.document.body | select innerhtml

     


    ¯\_(ツ)_/¯


    • Edited by jrv Thursday, September 13, 2012 4:46 PM
    Thursday, September 13, 2012 4:41 PM
  • Hi jrv:

    Thanxs for the reply, allthough didn't help at all.

    I think the question I've posted has everything to do with the original question, I know this post is old but i was hoping an answer was found and not posted, Perhaps the question was not correctly asked, but the actual problem is with a PowerShell script, tools like PowerGUI or VS were used just to have a better debugging and the PHP was an example.

    $Browser = New-Object -COM "InternetExplorer.Application"
    $Browser.Navigate($default_url)
    $RESULTS = $Browser.Document.getElementsByTagName("TABLE")
    ForEach ($table_result in $RESULTS){
    	if($table_result.className -match "main_table"){
                 #do something
              }
    }

    $table_result.className returns a class only if I run the script from VS, Powershell comand prompt has no idea of what this is, so i assumed has something to do with libraries.

    I will open a new topic.

    Thanxs.

     

    Friday, September 14, 2012 7:58 AM
  • Well
    finally got the solution:

    The PowerShell
    command prompt opens the 64bits version of internet explorer, and VS2010 runs
    the 32bits. Amazingly these two objects behave differently, so check which
    Internet explorer object the script is running.



    • Proposed as answer by CarlosValdes Friday, September 14, 2012 9:20 AM
    • Edited by CarlosValdes Friday, September 14, 2012 9:21 AM
    Friday, September 14, 2012 9:20 AM