{"id":15202973,"url":"https://github.com/nstevens1040/create-cookiecollectionfromjson","last_synced_at":"2026-03-09T10:31:12.608Z","repository":{"id":70278804,"uuid":"372079173","full_name":"nstevens1040/Create-CookieCollectionFromJson","owner":"nstevens1040","description":"Creates a CookieCollection object in PowerShell using the Json exported from the EditThisCookie browser extension.","archived":false,"fork":false,"pushed_at":"2021-07-03T21:00:55.000Z","size":6586,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-05T07:18:23.677Z","etag":null,"topics":["authenticated","cookiecollection","cookies","csharp","dotnet-core","dotnet-framework","editthiscookie","http-requests","httprequest","json","powershell-core","powershell-script","windows-powershell"],"latest_commit_sha":null,"homepage":"","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nstevens1040.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-05-29T22:20:12.000Z","updated_at":"2023-01-28T02:49:03.000Z","dependencies_parsed_at":"2023-02-24T09:30:47.338Z","dependency_job_id":null,"html_url":"https://github.com/nstevens1040/Create-CookieCollectionFromJson","commit_stats":{"total_commits":81,"total_committers":1,"mean_commits":81.0,"dds":0.0,"last_synced_commit":"7f6a16b01924c3c0550c52a4be2b75a596a2262e"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nstevens1040%2FCreate-CookieCollectionFromJson","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nstevens1040%2FCreate-CookieCollectionFromJson/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nstevens1040%2FCreate-CookieCollectionFromJson/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nstevens1040%2FCreate-CookieCollectionFromJson/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nstevens1040","download_url":"https://codeload.github.com/nstevens1040/Create-CookieCollectionFromJson/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241982637,"owners_count":20052535,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["authenticated","cookiecollection","cookies","csharp","dotnet-core","dotnet-framework","editthiscookie","http-requests","httprequest","json","powershell-core","powershell-script","windows-powershell"],"created_at":"2024-09-28T04:20:52.613Z","updated_at":"2026-03-09T10:31:12.383Z","avatar_url":"https://github.com/nstevens1040.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Create-CookieCollectionFromJson  \n*(Tested and working on both **Windows PowerShell 5.1** as well as **PowerShell Core 7.1.3**.)*  \n## PowerShell Quick Start  \n  \nI'm leaving this at the top of the page for convenience.  \nThe command below will make **Create-CookieCollectionFromJson** available in your current PowerShell session.  \n```ps1\niex (irm \"https://raw.githubusercontent.com/nstevens1040/Create-CookieCollectionFromJson/main/Create-CookieCollectionFromJson.ps1\")\n```  \n## What is Create-CookieCollectionFromJson?  \n  \nIt is a PowerShell script that creates a **[System.Net.CookieCollection](https://docs.microsoft.com/en-us/dotnet/api/system.net.cookiecollection?view=net-5.0)** object using the json exported from the **[EditThisCookie](https://www.editthiscookie.com)** browser extension.  \n\n## Use Case  \n  \nTogether with my other library **[Execute.HttpRequest](https://github.com/nstevens1040/Execute.HttpRequest)**, this script will alow you to make authenticated HTTP requests in Windows PowerShell via cookies.  \n  \nAlthough **[Execute.HttpRequest](https://github.com/nstevens1040/Execute.HttpRequest)** is fully functional in **Windows PowerShell** it does **not** work in **PowerShell Core** (yet).  \n  \n**A word of caution; please be smart while using your cookies. They are used to authenticate you.**  \n\n# Getting Started  \nInstall the [EditThisCookie](https://www.editthiscookie.com) browser extension (currently available for **Chrome** and **Opera**).  \n   - [Chrome](https://chrome.google.com/webstore/detail/editthiscookie/fngmhnnpilhplaeedifhccceomclgfbg)\n   - [Opera](https://addons.opera.com/en/extensions/details/edit-this-cookie)  \n\nOnce it's installed, you can identify the extension by it's cookie icon.  \n  \n\u003cimg height=344 width=320 src=\"https://raw.githubusercontent.com/nstevens1040/Create-CookieCollectionFromJson/main/.gitignore/1.PNG\"\u003e  \n  \nClick once on the cookie icon, then find the **export** button.  \n  \n\u003cimg height=344 width=320 src=\"https://raw.githubusercontent.com/nstevens1040/Create-CookieCollectionFromJson/main/.gitignore/2.PNG\"\u003e  \n  \nClick once on the **export** icon. The extension will let say **Cookies copied to the clipboard** in a small pop-up box.  \n  \n\u003cimg height=344 width=320 src=\"https://raw.githubusercontent.com/nstevens1040/Create-CookieCollectionFromJson/main/.gitignore/3.png\"\u003e  \n  \nOpen your favorite text editor and paste your cookies. Save the file with a **.json** file extension.  \n    \n\u003cimg height=360 width=640 src=\"https://raw.githubusercontent.com/nstevens1040/Create-CookieCollectionFromJson/main/.gitignore/1.gif\"/\u003e  \n  \n# How to use Create-CookieCollectionFromJson  \n  \n## PowerShell  \n  \nNow that you have your cookies in a json file, go ahead and launch **PowerShell**.  \n  \n**1.** To make the script available in your current PowerShell session, run the code below.  \n  \n```ps1\niex (irm \"https://raw.githubusercontent.com/nstevens1040/Create-CookieCollectionFromJson/main/Create-CookieCollectionFromJson.ps1\")\n```  \n  \n**2.** The script takes a string argument via the **-JsonFilePath** parameter.  \n  \n```ps1\nCreate-CookieCollectionFromJson -JsonFilePath \"$($ENV:USERPROFILE)\\Desktop\\cookies.json\"\n```  \n  \nThe script will notify you of it's success and let you know how to access the cookies.  \nIt creates a custom c# class with a property named (*your cookie domain*)_cookies.  \n  \n\u003cimg height=360 width=640 src=\"https://raw.githubusercontent.com/nstevens1040/Create-CookieCollectionFromJson/main/.gitignore/render1622658112677.gif\"/\u003e  \n  \nIn the example above, after I create my **CookieCollection** object the script tells me that it's accessible via **[Nstevens1040.Cookies]::nstevens1040_cookies.**  \n  \nTo view my CookieCollection's properties, I run  \n  \n```ps1\n[Nstevens1040.Cookies]::nstevens1040_cookies | select name,value,expires,secure,path,domain | ft -AutoSize\n```  \n  \n**3.** To use the CookieCollection in an HTTP request I load my other library, **[Execute.HttpRequest](https://github.com/nstevens1040/Execute.HttpRequest)**, into **Windows PowerShell** with the command below.  \n*(Step 3 onward works only in Windows PowerShell and not PowerShell Core)*  \n  \n```ps1\n[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12\niex (irm \"https://github.com/nstevens1040/Execute.HttpRequest/releases/download/v1.1.8/Quick-Start.ps1\")\n```  \n  \n**4.** Send my HTTP request  \n  \n```ps1\n$r = [Execute.HttpRequest]::Send(\n    \"https://nstevens1040.github.io/Create-CookieCollectionFromJson\",\n    [System.Net.Http.HttpMethod]::Get,\n    $null,\n    [Nstevens1040.Cookies]::nstevens1040_cookies\n)\n```  \n\nTo view the CookieCollection returned from the HTTP request  \n  \n```ps1\n$r.CookieCollection | select name,value,expires,secure,path,domain | ft -AutoSize\n```  \n  \n## CSharp  \n  \nLaunch **PowerShell**.  \n*(Tested in both Windows PowerShell and PowerShell Core)*  \n  \n**1.** To make the script available in your current PowerShell session, run the code below.  \n  \n```ps1\niex (irm \"https://raw.githubusercontent.com/nstevens1040/Create-CookieCollectionFromJson/main/Create-CookieCollectionFromJson.ps1\")\n```  \n  \n**2.** The script takes a string argument via the **-JsonFilePath** parameter and if you want the script to return the **C#** source use the **-ReturnCSharp** switch.  \n  \n```ps1\nCreate-CookieCollectionFromJson -JsonFilePath \"$($ENV:USERPROFILE)\\Desktop\\cookies.json\" -ReturnCSharp\n```  \n  \nThis will return the raw CSharp source code that you can use. Example output below  \n  \n```cs\nnamespace Nstevens1040\n{\n    using System.Net;\n    using System;\n    public class Cookies\n    {\n        public static CookieCollection nstevens1040_cookies = new CookieCollection(){            \n            new Cookie(){\n                Domain = \".nstevens1040.github.io\",\n                Expires = DateTime.Parse(@\"1970-01-01\").AddSeconds(1654093426),\n                HttpOnly = false,\n                Name = \"c_user\",\n                Path = \"/\",\n                Secure = true,\n                Value = \"017fcad9-d35f-4cad-900f-cca7d4079778\"\n            },\n            new Cookie(){\n                Domain = \".nstevens1040.github.io\",\n                Expires = DateTime.Parse(@\"1970-01-01\").AddSeconds(1654093426),\n                HttpOnly = false,\n                Name = \"datr\",\n                Path = \"/\",\n                Secure = true,\n                Value = \"561f7746-5046-4416-888e-127f9b881ae0\"\n            },\n            new Cookie(){\n                Domain = \".nstevens1040.github.io\",\n                Expires = DateTime.Parse(@\"1970-01-01\").AddSeconds(1654093426),\n                HttpOnly = false,\n                Name = \"dpr\",\n                Path = \"/\",\n                Secure = true,\n                Value = \"6735c335-451a-4bab-afa2-83505dfa13ff\"\n            },\n            new Cookie(){\n                Domain = \".nstevens1040.github.io\",\n                Expires = DateTime.Parse(@\"1970-01-01\").AddSeconds(1654093426),\n                HttpOnly = false,\n                Name = \"fr\",\n                Path = \"/\",\n                Secure = true,\n                Value = \"04f05394-6ce8-4673-bc8a-80c9461b9467\"\n            },\n            new Cookie(){\n                Domain = \".nstevens1040.github.io\",\n                Expires = DateTime.Parse(@\"1970-01-01\").AddSeconds(1654093426),\n                HttpOnly = false,\n                Name = \"sb\",\n                Path = \"/\",\n                Secure = true,\n                Value = \"11db0dc0-522c-4f96-9e91-37a3bae38306\"\n            },\n            new Cookie(){\n                Domain = \".nstevens1040.github.io\",\n                Expires = DateTime.Parse(@\"1970-01-01\").AddSeconds(1654093426),\n                HttpOnly = false,\n                Name = \"spin\",\n                Path = \"/\",\n                Secure = true,\n                Value = \"9f584b69-92bc-4077-9e73-0b531b1b4592\"\n            },\n            new Cookie(){\n                Domain = \".nstevens1040.github.io\",\n                Expires = DateTime.Parse(@\"1970-01-01\").AddSeconds(1654093426),\n                HttpOnly = false,\n                Name = \"test_cookie\",\n                Path = \"/\",\n                Secure = true,\n                Value = \"acac9822-dc7a-4199-8ac4-a51a032b2cbc\"\n            },\n            new Cookie(){\n                Domain = \".nstevens1040.github.io\",\n                Expires = DateTime.Parse(@\"1970-01-01\").AddSeconds(1654093426),\n                HttpOnly = false,\n                Name = \"xs\",\n                Path = \"/\",\n                Secure = true,\n                Value = \"70cb6d9c-9483-4ba7-a4b3-9901813aa558\"\n            }\n        };\n    }\n}\n```  \n  \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnstevens1040%2Fcreate-cookiecollectionfromjson","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnstevens1040%2Fcreate-cookiecollectionfromjson","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnstevens1040%2Fcreate-cookiecollectionfromjson/lists"}