Powershell: How to Automatically Populate the Fields of a "Windows Security" Prompt Window to Access a web Page

681 Views Asked by At

This is my first question on Stack Overflow so please forgive me if it comes off a little vague. In the case that it happens to be, I'll be more than happy to clarify to the best of my ability.

So, I'm trying to automatically login to an IP that requires authorization to do some web scraping. Upon navigating to the URL this window comes up. Is there a method/property that can auto-fill the username/password fields in this window?

Windows Security Window with Username/Password fields

Here's what i have so far

function Initialize-IE {
param([system.string]$url,
      [System.Boolean]$isVisible)
$ie = New-Object -ComObject internetexplorer.application
$ie.visible = $isVisible
$ie.navigate($url)
while ($ie.Busy -eq $true) {Start-Sleep -seconds 1;} 
return $ie

}

Initialize-IE -url "10.10.205.63" -isVisible $false

On an additional note: I know this is possible to do using invoke-webrequest with the credential parameter. However, there's a button on this web page that requires the user to click on it a number of times in order for an inline script to execute and return the information i need. And the only way that i know of to simulate the button press is through grabbing the element through the internet explorer object and using the click() method. So, if there's an alternative way using the invoke-webrequest method feel free to post it.

0

There are 0 best solutions below