Skip to content

Instantly share code, notes, and snippets.

@ilidemi
Created June 9, 2018 21:33
Show Gist options
  • Save ilidemi/6e066e6a223ce5f56ef7fab0ab6f238c to your computer and use it in GitHub Desktop.
Save ilidemi/6e066e6a223ce5f56ef7fab0ab6f238c to your computer and use it in GitHub Desktop.
Invoke-WebRequest with inline cookies
Invoke-WebRequest -WebSession (New-Object Microsoft.PowerShell.Commands.WebRequestSession -Property @{Cookies=(Invoke-Command { $ck = New-Object System.Net.CookieContainer; $ck.Add((New-Object System.Net.Cookie -Property @{Name="name1"; Value="value1"; Domain="domain1.com"})); $ck.Add((New-Object System.Net.Cookie -Property @{Name="name2"; Value="value2"; Domain="domain2.com"})); $ck })})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment