Authenticating too and working with a java based web site.

I have a very old web site that I need to be able to authenticate to navigate a few pages, and input data such as user names and have the site generate its pdf username reports. All of this can be done manually just as a normal web site users, but trying to automate it as I have to generate a report for about 1,000 users and each report takes minutes to run. On the authentication page I see the fields are pwd and user using google chrome dev tools. Beyond that have tinkered with creating a com object and invoke-webrequest but did not get very far. Is this even possible in powershell? Can somebody point me in a direction that may help. I have poked around the internet but have not seen much that matches what I am trying to do.

Yes, you can scrape a website, and send logon data.

This also sounds like you are new to PowerShell, and more specifically, website scraping. There are ton of sample scripts and info on using PowerShell for web scraping, or web site interaction. Just do a search for ‘PowerShell, login to a site’ or ‘PowerShell web scraping’.

So, be sure to jump on YouTube or use one of the many free eBooks on this site to wrap your head around all this.

Looking at the page source via a browser tool is useful, but you can do that directly with PowerShell.

Invoke-WebRequest is used for that. Example:

The use of the extra parenthesis is something call variable squeezing, that assigns the results to the variable, but also send to the screen, it’s not needed for normal operations.

$url = 'https://pwpush.com'
($FormElements = Invoke-WebRequest -Uri $url -SessionVariable fe  )
($Form = $FormElements.Forms[0] | Format-List -Force)
$Form | Get-Member
$Form.Fields


# so you end up with something like this....

$password = '1234'
$loginUrl = 'https://pwpush.com'

$ie = New-Object -com internetexplorer.application
$ie.visible = $true
$ie.navigate($loginUrl)

while ($ie.Busy -eq $true) { Start-Sleep -Seconds 1 }

($ie.document.getElementById('password_payload') | select -first 1).value = $password
Start-Sleep -Seconds 1 

$ie.Document.getElementsByName('commit').Item().Click();
Start-Sleep -Seconds 1 

Thanks for the response, but I have already gotten that far.

PS C:> $test = new-object -ComObject internetexplorer.application
PS C:> $test.navigate(“xxx”)
PS C:> $test.visible = $true
PS C:> $test.document.getelementbyid()| gm
PS C:> $test.document.getelementbyid()
System.__ComObject
PS C:>

I think my problem is that when I do the above it returns a “System.__ComObject”. I decided to look into that method because when ever I run the script I get an error “The property ‘value’ cannot be found on this object. Verify that the property exists and can be set.” Maybe the Javascript is causing issues here.