For this purpose, the best option is to ask the provider (if possible) to publish some API.
For this purpose, sending keystrokes is very fragile. What after clicking the "Save" button? A dialog box will open, and you should go to the folder and click "OK." This means you need to find the window again. But what if some kind of similar window opens? Will your script find the right window? (for other scenarios where you need to hide / show / find windows and send keystrokes, I would recommend Autohotkey .)
Other features depend on which site it is. It seems that the file is being generated as a response to the POST command. This means that there is no direct link that you could download. And even if there was a link, it is likely that it could not be downloaded via Net.WebClient , because you would not send any authentication information (session cookies or session identifier in the query string). You will need to make out, for example. cookies from $ie.Document.cookie and add them to the request.
However, in some cases, you can use [System.Net.WebRequest]$webRequest = [System.Net.WebRequest]::Create($url); and specify the POST method and data and wait for a response (which will be a file). This would emulate a click on the submit button. But then again, without credentials, this is likely to fail.
Without access to the site, itβs hard to say anything else.
source share