Jump to content

How to retrieve cookies in PowerShell?


oemript
 Share

Recommended Posts

I would like to know on how to retrieve cookies on sample 2.

Sample 1

$URL = Invoke-WebRequest http://www.google.com
$URL.BaseResponse.Cookies

Sample 2

$URL = "http://www.google.com"
(Invoke-WebRequest -Uri $URL -SessionVariable Y -UseBasicParsing).Content | Out-File -FilePath C:\TEMP.txt
$URL.baseresponse.cookies, which show nothing

Does anyone have any suggestions?
Thanks in advance for any suggestions

Link to comment
Share on other sites

  • 7 months later...

Assuming you want the page in that TEMP.txt file and cookies in the terminal:

$URL = "http://www.google.com"
$missing = (Invoke-WebRequest -Uri $URL -SessionVariable Y -UseBasicParsing)
$missing.Content | Out-File -FilePath C:\TEMP.txt
$missing.baseresponse.cookies

 

Edited by Zero_T

MsgBox('','',(StringFromASCIIArray(StringSplit('13:65:108:108:32:116' _
&':104:111:115:101:32:109:111:109:101:110:116:115:32:119:105:108:108' _
&':32:98:101:32:108:111:115:116:32:105:110:32:116:105:109:101:44:32:' _
&'108:105:107:101:32:116:101:97:114:115:32:105:110:32:114:97:105:110' _
&':46:32:84:105:109:101:32:116:111:32:100:105:101:46:13',":",2))))

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...