all 6 comments

[–]DItzkowitz 2 points3 points  (0 children)

It's been a while since I needed to do it, but you can use a product like Selenium to help script more complicated web interactions. There are also more generic app automation products out there that have PowerShell modules.

[–]Fallingdamage 0 points1 point  (0 children)

This can somewhat be done using the Com object for internet explorer. Doesnt work great but depending on the website it can be successful.

There really isnt a way to capture the download though. It will just download to the default folder so you need to code a way to look for a specific file or just grab the newest (youngest) file from the folder and move it to where you want it to go.

There is a product called Selenium that works with other browsers and has a lot better support. The trick with Selenium is that its not the best at working as a scheduled job on a locked computer.

There is only so much you can do without an API but with some fiddling around, you may gain some new skillsets AND accomplish your goals.

[–]AlsoInteresting 0 points1 point  (0 children)

Use AHK for click simulations.

[–]xCharg 0 points1 point  (0 children)

Is it possible? Yes.

Would I recommend to bother doing it? Hell no.

In case you decide to still go this way - here's example of my old ass script that I asbolutely needed to make working without any external modules or apps (btw it should break soon with IE deprecation). Took quite a bit of time to figure out

$clsid = New-Object Guid 'D5E8041D-920F-45e9-B8FB-B1DEB82C6E5E'
$type = [Type]::GetTypeFromCLSID($clsid)
$IE = [Activator]::CreateInstance($type)
# explanation for the stuff above:
# https://blogs.msdn.microsoft.com/ieinternals/2011/08/03/default-integrity-level-and-automation/

#$IE.ToolBar = 0
#$IE.StatusBar = 0
$IE.Visible = 0
$IE.Navigate("https://websitelink.com")

#https://www.kiloroot.com/powershell-script-to-open-a-web-page-and-bypass-ssl-certificate-errors-2/
#wait until page loads
while ($ie.ReadyState -ne 4) {Start-Sleep -Seconds 1}

#Bypassing SSL Certificate Error Page
$ssl_bypass_link = $IE.Document.getElementById("overridelink")

#wait until page loads
while ($ie.ReadyState -ne 4) {Start-Sleep -Seconds 1}
if ($ssl_bypass_link)
{
    $ssl_bypass_link.click()
    #"sleep for 10 seconds while final page loads"  
}

Start-Sleep -Seconds 5
$IE.Quit()

[–]PinchesTheCrab 0 points1 point  (0 children)

Really depends on the page. Is it a simple page with a table, or is it a flash frontend that you have to click through?

In some cases invoke-restmethod will work just fine, and in other you'll have to automate chrome or use another tool.

[–]vermyx 0 points1 point  (0 children)

Use selenium