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() }