Script open IE, press “okay” on cert selection, “open” file, close IE window

Im trying to create a script to Open an internet explorer window to a link, which i've worked out. But then i need it to click "OKAY" when a windows security certificate pops up, then click "open" when it asks to download the file (link points to a file, rather than a page), and then close the IE instance that it had just opened. Im unsure if the "open" with the file download works, as i cannot get past the cert slection beforehand.

 

Open IE link:

 

    $IE = New-Object -comObject InternetExplorer.Application.1 ; $IE.visible = $True

    $IE.Navigate("https://website.com/file.exe")

 

I've also found this code that will press okay for the certificate selection if i know the button ID, but i can't seem to find the button ID for the cert selection window:

 

    while ($IE.busy) {

    sleep -milliseconds 50

    }

        sleep -milliseconds 500

        $doc = $IE.document

        sleep -milliseconds 500

        $btn = $doc.getElementByID("button ID you can see in the source of the page")

    $btn.Click()

 

Click "open" on the file download:

 

    Select-Window iexplore | Select-Control -Class "Frame Notification Bar" | Send-Keys "%S"

 

Close IE window. This currently closes all IE instances, is there a way to just close the one it had opened to begin with?

 

    Get-Process iexplore | Foreach-Object { $_.CloseMainWindow() }

 

 


February 27th, 2014 10:38am


 

Close IE window. This currently closes all IE instances, is there a way to just close the one it had opened to begin with?

 

    Get-Process iexplore | Foreach-Object { $_.CloseMainWindow() }

 


$IE.Quit() will do that.
Free Windows Admin Tool Kit Click here and download it now
February 27th, 2014 10:58am

The security pop up, is that a certificate warning? - If so, if you trust the certificate, you can choose to install it into your certificate store. Then you will not get the warning again.
February 27th, 2014 11:01am

$IE.quit() doesnt work for now, but i think its because of the Certificate pop-up and download pop-up.

Its a Certificate selection window. Normally this wasn't displayed in XP because we were able to disable the prompt when there was only one cert displayed. We've upgraded to win7 and are in the process to the that function back from our admins.



Free Windows Admin Tool Kit Click here and download it now
February 27th, 2014 11:25am

I came up with a better workaround. I'm going to save the files to be opened to a network share, so i can delegate access to the file as well as the script.

But that last question still remains, can i automate when the file link is opened, to click "open" in the download file prompt?


February 27th, 2014 11:36am

Nevermind, since i'm storing the file on a fileshare, i'll just use 'invoke-item'. That's a lot easier
Free Windows Admin Tool Kit Click here and download it now
February 27th, 2014 12:13pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics