title: How can I make this PowerShell web request save the session properly?
body: <p>I have this script that successfully logs into a website and performs a query:</p>
  
  <pre><code>$credential = Get-Credential
  
  $postParams = @{username=$credential.UserName;password=$credential.GetNetworkCredential().password}
  
  Invoke-WebRequest -Uri http://www.nexusmods.com/newvegas/sessions/?Login -Method POST -Body $postParams -SessionVariable cookie
  
  $query = Invoke-WebRequest -Uri http://www.nexusmods.com/newvegas/mods/searchresults/? -WebSession $cookie
  </code></pre>
  
  <p>What I am trying to do is do a similar thing with another website, Trello. This is the script:</p>
  
  <pre><code>$credential = Get-Credential
  
  $postParams = @{method='password';'factors[user]'=$credential.UserName;'factors[password]'=$credential.GetNetworkCredential().password}
  
  Invoke-WebRequest -Uri https://trello.com/1/authentication -Method POST -Body $postParams -SessionVariable cookie
  
  $result = Invoke-WebRequest -uri https://trello.com/ -WebSession $cookie
  </code></pre>
  
  <p>However, result variable displays a page as if the user was not logged in, so I'm assuming the session isn't properly saving. How can I fix this?</p>