I'm trying to write a powershell script that logs onto a website via an html form using post but I can't get it to log on. All that happens is the page loads and then I get a 403 error.
I'm not even sure if the file will download the file if it logs on as I still get a 403 error if I manually log on to the website and then run the download file code. The code for downloading the file does work though as I've used it elsewhere.
Here's the code I'm using:
Code:
$ie = New-Object -com internetexplorer.application;
$ie.visible = $true;
$ie.navigate($url);
while ($ie.Busy -eq $true)
{
Start-Sleep -Milliseconds 1000;
}
$ie.Document.getElementById("email").value = $username;
$ie.Document.getElementById("password").value=$password;
$ie.Document.getElementsByTagName("input") |
Where-Object { $_.Name -eq "sign_in" } |
ForEach-Object { $_.Click() }
$webclient = New-Object System.Net.WebClient
$webclient.DownloadFile($url2, $file)
Can someone help?