I have this script that successfully logs into a website and performs a query:
$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
What I am trying to do is do a similar thing with another website, Trello. This is the script:
$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
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?