I am trying to get/parse data from a website. The website requires autherntication (username,password).
When my script runs, it returns the authentication page. This implied that its not authenticating. Any ideas on how to get this done?
The only thing that I can think of is that I need to pass $request.Credentials to the WebRequest somehow, but I cant find anything on this.
Here is the powershell code that I am using I removed url names, passwords, etc for obvious reasons.
thanks,
Jose
function Get-URL{
$url = "somesite.somedomain.jsp"
[net.httpWebRequest] $request = [net.webRequest]::create($url)
$request.Credentials = New-Object Net.NetworkCredential("user", "password")
[net.httpWebResponse] $response = $request.getResponse()
$responseStream = $response.getResponseStream()
$sr = new-object IO.StreamReader($responseStream)
$result = $sr.ReadToEnd()
$result
}
Get-URL