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

Hello,

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

$ie = getIeInstance "www.experts-exchange.com"

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?
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.

[InternetExplorer.Application]
0
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)]
    Param
    (
        [Parameter(Mandatory=$true)]
        $Url
    )
# 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
      $ie.top = 600; $ie.width = 900; $ie.height = 400; $ie.Left = 1000;
   
    $ie.navigate("$Url")

    return $ie
}

# using $ie instance :
$loadingUrl = "C:\script\loading.html"
$SamlUrl = "http://www.experts-exchange.com"

# 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
#$ie.navigate($SamlUrl)
$ie.navigate($SamlUrl)


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

thank you in advance for further help.

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

$ie.Navigate("$Url")
0
Introducing the "443 Security Simplified" Podcast

This new podcast puts you inside the minds of leading white-hat hackers and security researchers. Hosts Marc Laliberte and Corey Nachreiner turn complex security concepts into easily understood and actionable insights on the latest cyber security headlines and trends.

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 ?
0
Bob LearnedCommented:
There is supposed to be an option to accept your answer as a solution.
0
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.

toshi
0

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
0
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
Powershell

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.