I have been having a lot of success using invoke-webrequest to log in to websites but I'm stumped. I am trying to log into https:// ctslink.com or https:// direct.ctslink.com. The login form has a hidden token field which changes every time I try to login, I believe is what is causing the problem. Another thing I noticed was the session variable $fb is null after the first call to invoke-webrequest.
$r=Invoke-WebRequest www.ctslink.com -SessionVariable $fb
$form = $r.Forms[0]
$form.Fields["userId"] = "MyUsername"
$form.Fields["passwd"] = "MyPassword"
$r=Invoke-WebRequest 'https://ctslink.com/login.do' -WebSession $fb -Body $form.Fields
Any help would be greatly appreciated, Mike