I have a powershell script that logs into a webpage. The command for this acction is the following:
$responseLogin = Invoke-WebRequest -Uri $urlLogin -Body $loginPayload -Method "POST" -SessionVariable session -MaximumRedirection 0 -SkipHttpErrorCheck -ErrorAction SilentlyContinue
With this what I pretend is to capture session cookies into the variable $session and use them in later requests to the same endpoint.
Here is the thing:
On a pc with PowerShell 7.3.1
$responseLogin.Headers.'Set-Cookie'
gives me 5 cookies: JSESSIONID, COOKIE_SUPPORT, GUEST_LANGUAGE_ID, COMPANY_ID and IDThis cookies are passed to the
$session
variable as expected, so$session.cookies.getAllcookies().Name
gives me exactly the same cookies and the rest of the requests works fine.On a pc with PowerShell 7.4.0
$responseLogin.Headers.'Set-Cookie'
gives me 5 cookies, but two are different: JSESSIONID, COOKIE_SUPPORT, GUEST_LANGUAGE_ID, REMEMBER_USER_CN, REMEMBER_USER_SNBut now
$session
only has 3, so$session.cookies.getAllcookies().Name
: JSESSIONID, COOKIE_SUPPORT, GUEST_LANGUAGE_ID. From here, I'm unable to perform further requests since im not really logged in.
Code is exactly same, only "apparent" difference is Powershell version.
Any ideas for this behaviour?
EDIT: Well, i can confirm now that is not a Version Related Issue... I've installed Powershell 7.3.11 on the PC that does not work, and the behaviour is the same... What else could be? Some remote server block to my IP? or my MAC somehow?
EDIT2: Further tests... On a VM(w10) inside my PC it does not work either!!!. On my Ubuntu23.0 IT DOES NOT WORK EITHER!!. On my personal Laptop(w11), it works even on 7.4.1. That discards IP blocking (Laptop, VM and PC had same outgoing IP and even used VPN for changing it...) so im starting to think in some Internet configuration from my side. This would make sense only for windows, but since I have same behaviour on Ubuntu, im thinking on a Hardware related (both linux and windows runs on same ethernet card) issue... Question is, which configuration is affected by Invoke-WebRequest? Can they, somehow, bloc my MAC address if we are not on the same network (i've seen other questions that is kinda impossible)
I'm about to format the PC for now... no kidding
Still clueless