1

I have a PowerShellScript that will call a webpage and the webpage is doing some code-behind work. The issue I am trying to resolve is that I'd like to make the webpage as a secured web page, but once I do that, I couldn't figure out a way to pass the username and password to the secured webpage from PowerShell Script. I am using the form authentication. I'd appreciate if anyone could provide a completed code sample so that I can just plug-in and do the magic. Thanks so much!

p.s. I've already tried the System.Net.NetworkCredential, but it seems it is for the basic authentication.

$url = "someurl"
$webclient = New-Object System.Net.WebClient
$webclient.DownloadString($url)

1 Answers1

0

Need a little more information. You may be able to solve your issue with the following answer

How to post data to specific URL using WebClient in C#

But I'm curious, what page you are submitting your authentication form to? That page would have this information. If the form is returning data into PS variables. Then the above link shows how to post directly to a page

Community
  • 1
  • 1
Schlauge
  • 483
  • 1
  • 4
  • 7
  • Well, the above link contains C# code, not PowerShell Script. I am new to PowerShell Script, so does PowerShellScript also have header field in the webclient and UploadString function? I am posting the form authentication to the login.aspx page and then redirect it to another .aspx page to get the data. I just came across another issue, I am using the login control in the login.aspx, and the password textbox is readonly, there seems no way for me to pre-populate the username and password and do a post to the form. – Superman Coding Jul 16 '13 at 22:04