Skip to content

Instantly share code, notes, and snippets.

@ilidemi
ilidemi / WebRequestWithCookies.ps1
Created June 9, 2018 21:33
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 })})