0

Currently I encountered an issue, I want to create a com IE object and navigate to a web page with PowerShell, then I can get the returned HTML document. But after the code executed I found the COM object I created changed (the method and properties got lost). Does anyone know why?

Here's the code:

$uri = "http://10.22.21.16:8080/tfs/web/wi.aspx?wit=Change&%5BSystem.Title%5D"

$IEObject = New-Object -ComObject InternetExplorer.Application

$IEObject.Visible = $true
$IEObject.Navigate($uri)

while ($IEObject.Busy) {
    Start-Sleep 1
}

$IEObject.Document

Here's the $IEObject before $Object.Navigate($uri):

enter image description here

TypeName: System.__ComObject#{d30c1661-cdaf-11d0-8a3e-00c04fc9e26e}

Name                 MemberType Definition
----                 ---------- ----------
ClientToWindow       Method     void ClientToWindow (int, int)
ExecWB               Method     void ExecWB (OLECMDID, OLECMDEXECOPT, Variant, Variant)
GetProperty          Method     Variant GetProperty (string)
GoBack               Method     void GoBack ()
GoForward            Method     void GoForward ()
GoHome               Method     void GoHome ()
GoSearch             Method     void GoSearch ()
Navigate             Method     void Navigate (string, Variant, Variant, Variant, Variant)
Navigate2            Method     void Navigate2 (Variant, Variant, Variant, Variant, Variant)
PutProperty          Method     void PutProperty (string, Variant)
QueryStatusWB        Method     OLECMDF QueryStatusWB (OLECMDID)

But after $IEobject.navigate($URI) it changed to:

TypeName: System.__ComObject

Name                      MemberType Definition
----                      ---------- ----------
CreateObjRef              Method     System.Runtime.Remoting.ObjRef CreateObjRef(type requestedType)
Equals                    Method     bool Equals(System.Object obj)
GetHashCode               Method     int GetHashCode()
GetLifetimeService        Method     System.Object GetLifetimeService()
GetType                   Method     type GetType()
InitializeLifetimeService Method     System.Object InitializeLifetimeService()
ToString                  Method     string ToString()

I can't get any HTML document.

Does anyone know why?

Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328
mxy
  • 37
  • 1
  • 8

0 Answers0