I'm trying to convert a relatively simple bash script to run in Windows. It uses wget to download a file from a site that requires a login name but no password. I have been bashing my head against invoke-webrequest in Powershell for some time.
Working script, lightly obfuscated:
Login and grab the auth cookies & link
wget --save-cookies /tmp/cookie.txt --keep-session-cookies --post-data 'login=myusername' -O /tmp/session.output https://website.com/session
Parse out the link and use the cookies to grab the digest
wget --load-cookies /tmp/cookie.txt -O "/home/user/filename$(date "+%Y-%m-%d").pdf" "https://website.com"
grep -o -E '/my-subscriptions/nnn/([^"#]+)pdf' /tmp/session.output
Clean up
rm /tmp/cookie.txt
rm /tmp/session.output