The following example works when designing the form in PowerShell studio and pressing RUN (F5) to run it (basically, open a web page and wait for READYSTATE to be 4 which is "page is done loading'"), it will print the $ie.ReadyState to console correctly while looping until page is done loading:
Code: Select all
$button1_Click={
$ie = New-Object -ComObject 'InternetExplorer.Application'
$ie.visible = $true
$ie.navigate("http://ipl0000")
$ie.fullscreen = $true
while ($ie.ReadyState -ne 4)
{
Write-Host "$($ie.ReadyState)"
Start-Sleep 3
[System.Windows.Forms.Application]::DoEvents()
}
msg * DONE
}
An interesting observation is that if i check the object $ie WHEN RAN FROM POWERSHELL STUDIO, it contains all the properties, including ReadyState:
Code: Select all
Application : System.__ComObject
Parent : System.__ComObject
Container :
Document : mshtml.HTMLDocumentClass
TopLevelContainer : True
Type : Document HTML
Left : 0
Top : 0
Width : 1920
Height : 1200
LocationName : Lexmark MS621dn
LocationURL : http://ipl0000/
Busy : False
Name : Internet Explorer
HWND : 1317918
FullName : C:\Program Files (x86)\Internet Explorer\IEXPLORE.EXE
Path : C:\Program Files (x86)\Internet Explorer\
Visible : True
StatusBar : False
StatusText :
ToolBar : 0
MenuBar : True
FullScreen : True
ReadyState : 4
Offline : False
Silent : False
RegisterAsBrowser : False
RegisterAsDropTarget : True
TheaterMode : False
AddressBar : False
Resizable : False
Checking that exact some object using the exact same code but ran from a saved .ps1 or packaged .exe, that object (which should be the same) is actually empty, containing only:
System.__ComObject
Much appreciated!