How to do wget with cookies in PowerShell

Question:

I want try transfer my bash script from linux to powershell but cant understand why it failed.

Linux command:

powershell code:

but this code only download page without cookies. And i cant find how i can send PHPSESSID to site.

Please explain to me how to do it.

Answer:

Ok so you have two options.

  1. Run wget on Windows.
  2. Set properties on the webclient object to
    replicate the functionality set by the wget flags.

The first one is easy, just download the Windows version of wget.

Here is the code for the second one.

Look inside your cookies.txt file to get the name value pairs.

I’m not sure how to replicate the -x functionality of wget. Give the above a try and see what it does with the file after downloading.

Note – I can’t test this…

Source:

How to do wget with cookies in PowerShell by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply