title: Powershell Invoke-WebRequest Login to website not working
body: <p>I am trying to write a Powershell script that will login to and navigate a website. When trying to POST the login credentials, however, I'm getting the error "Server Error in '/Webpostage' Application.". I have no issue with logging in manually using a browser. I've tried using the same URI for both requests as well as using the Developer network monitor in Chrome to capture the actual URI of the POST (shown below). Any ideas?</p>
  
  <pre><code>$Username = "username"
  $Password = "password"
  
  # GET Stamps.com Login page
  $R = Invoke-WebRequest https://print.stamps.com/webpostage/signin/default.aspx -SessionVariable StampsCom
  $Form = $R.Forms[0]
  
  # Fill in login credentials
  $Form.Fields["UserNameTextBox"] = $Username
  $Form.Fields["PasswordTextBox"] = $Password
  
  # Login to Stamps.com
  $R = Invoke-WebRequest -Uri ("https://print.stamps.com/webpostage/ajax/AuthenticateUser.aspx?LoginSource=SigninPage" + $Form.Action) -WebSession $StampsCom -Method POST -Body $Form.Fields
  </code></pre>