how to have access to methods of the comobject "InternetExplorer.Application" once passed from a function ?


I've created a function "get-IeInstance" that return an object "InternetExplorer.Application".

$ie = getIeInstance ""

then from the caller script i can not use any method on $ie variable ?
i receive message error like :
Method invocation failed because [System.__ComObject] doesn't contain a method named 'quit'.

do i have to cast my variable in order to reach the method of the "InternetExplorer.Application"  ?

how can i do in order to have my $ie variable recongnize as an InternetExplorer.Application instance ?

thank you for your help.
Erwin PombettAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bob LearnedCommented:
Yes, I believe that you have to set a specific type for the variable.

Erwin PombettAuthor Commented:
hello Bob,

Sorry for the delay.

actually i can not figure it out....

here's a function declaration and calls from the same file.

more strange : i've notice that i can not set $ie.navigating($url) before the lines were i set $ie.AddressBar= $false.
i i do so, $ie.AddressBar is not recognize.

Function GetIeInstanceWithURL
    [CmdletBinding(SupportsShouldProcess = $true)]
# get new instance of IEopowero

    $ie = New-Object -ComObject InternetExplorer.Application
    $ie.visible = $True

    start-sleep 2
# config IE display
    $ie.AddressBar= $false; $ie.MenuBar = $false
    $ie.Resizable = $false ; $ie.ToolBar = $false
# config IE window size and position
      $ = 600; $ie.width = 900; $ie.height = 400; $ie.Left = 1000;

    return $ie

# using $ie instance :
$loadingUrl = "C:\script\loading.html"
$SamlUrl = ""

# 1
#$ie = [InternetExplorer.Application] (GetIeInstanceWithURL $loadingUrl)     <-   ko Unable to find type [InternetExplorer.Application]: make sure that the assembly containing this type is loaded.

# 2  
[InternetExplorer.Application]  $ie = GetIeInstanceWithURL $loadingUrl    <-   Method invocation failed because [System.__ComObject] doesn't contain a method named  'navigate'.

# usage

how can i have access to methods in "InternetExplorer.Application"
what am i missing  ?

thank you in advance for further help.

Bob LearnedCommented:
The method should be case-sensitive, so try this:

Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

Erwin PombettAuthor Commented:
i found the problem.

this is an IE configuration problem.
After i move down the cursor from IE security for internet the code is working the method were recongnised for the $IE object.

the strange thing is that after i move it up the code still running.

thank you very much for your help.

what I'm supposed to do with the points ?
Bob LearnedCommented:
There is supposed to be an option to accept your answer as a solution.
Erwin PombettAuthor Commented:
thank you Bob,

After having mixed myself up with all the changes i did.

I'm now sure that what's necessary is to start the script as admin.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Erwin PombettAuthor Commented:
the script has to get started as admin
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.